@devtable/settings-form 12.10.1 → 12.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(C
|
|
1
|
+
(function(j,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("react"),require("@mantine/core"),require("@mantine/notifications"),require("tabler-icons-react"),require("crypto-js"),require("axios"),require("react-hook-form"),require("ahooks"),require("@monaco-editor/react"),require("@mantine/modals"),require("@tabler/icons-react"),require("@mantine/hooks")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/notifications","tabler-icons-react","crypto-js","axios","react-hook-form","ahooks","@monaco-editor/react","@mantine/modals","@tabler/icons-react","@mantine/hooks"],C):(j=typeof globalThis<"u"?globalThis:j||self,C(j["settings-form"]={},j.react,j["@mantine/core"],j["@mantine/notifications"],j["tabler-icons-react"],j.CryptoJS,j.axios,j["react-hook-form"],j.ahooks,j["@monaco-editor/react"],j["@mantine/modals"],j["@tabler/icons-react"],j["@mantine/hooks"]))})(this,function(j,C,f,D,ie,gn,hn,k,he,Pe,_e,ce,mn){"use strict";function bn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const vn=bn(gn);var it={exports:{}},Be={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var vt;function yn(){if(vt)return Be;vt=1;var e=
|
|
9
|
+
*/var vt;function yn(){if(vt)return Be;vt=1;var e=C,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function l(d,p,g){var m,c={},u=null,h=null;g!==void 0&&(u=""+g),p.key!==void 0&&(u=""+p.key),p.ref!==void 0&&(h=p.ref);for(m in p)r.call(p,m)&&!s.hasOwnProperty(m)&&(c[m]=p[m]);if(d&&d.defaultProps)for(m in p=d.defaultProps,p)c[m]===void 0&&(c[m]=p[m]);return{$$typeof:t,type:d,key:u,ref:h,props:c,_owner:i.current}}return Be.Fragment=n,Be.jsx=l,Be.jsxs=l,Be}var ze={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var yt;function Sn(){return yt||(yt=1,process.env.NODE_ENV!=="production"&&function(){var e=
|
|
17
|
+
*/var yt;function Sn(){return yt||(yt=1,process.env.NODE_ENV!=="production"&&function(){var e=C,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),d=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),y=Symbol.iterator,b="@@iterator";function w(o){if(o===null||typeof o!="object")return null;var S=y&&o[y]||o[b];return typeof S=="function"?S:null}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(o){{for(var S=arguments.length,_=new Array(S>1?S-1:0),T=1;T<S;T++)_[T-1]=arguments[T];A("error",o,_)}}function A(o,S,_){{var T=E.ReactDebugCurrentFrame,L=T.getStackAddendum();L!==""&&(S+="%s",_=_.concat([L]));var $=_.map(function(R){return String(R)});$.unshift("Warning: "+S),Function.prototype.apply.call(console[o],console,$)}}var O=!1,q=!1,X=!1,P=!1,Y=!1,B;B=Symbol.for("react.module.reference");function J(o){return!!(typeof o=="string"||typeof o=="function"||o===r||o===s||Y||o===i||o===g||o===m||P||o===h||O||q||X||typeof o=="object"&&o!==null&&(o.$$typeof===u||o.$$typeof===c||o.$$typeof===l||o.$$typeof===d||o.$$typeof===p||o.$$typeof===B||o.getModuleId!==void 0))}function F(o,S,_){var T=o.displayName;if(T)return T;var L=S.displayName||S.name||"";return L!==""?_+"("+L+")":_}function K(o){return o.displayName||"Context"}function G(o){if(o==null)return null;if(typeof o.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case i:return"StrictMode";case g:return"Suspense";case m:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case d:var S=o;return K(S)+".Consumer";case l:var _=o;return K(_._context)+".Provider";case p:return F(o,o.render,"ForwardRef");case c:var T=o.displayName||null;return T!==null?T:G(o.type)||"Memo";case u:{var L=o,$=L._payload,R=L._init;try{return G(R($))}catch{return null}}}return null}var Q=Object.assign,M=0,ne,Z,ee,le,ue,de,Se;function re(){}re.__reactDisabledLog=!0;function pe(){{if(M===0){ne=console.log,Z=console.info,ee=console.warn,le=console.error,ue=console.group,de=console.groupCollapsed,Se=console.groupEnd;var o={configurable:!0,enumerable:!0,value:re,writable:!0};Object.defineProperties(console,{info:o,log:o,warn:o,error:o,group:o,groupCollapsed:o,groupEnd:o})}M++}}function we(){{if(M--,M===0){var o={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Q({},o,{value:ne}),info:Q({},o,{value:Z}),warn:Q({},o,{value:ee}),error:Q({},o,{value:le}),group:Q({},o,{value:ue}),groupCollapsed:Q({},o,{value:de}),groupEnd:Q({},o,{value:Se})})}M<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=E.ReactCurrentDispatcher,He;function Re(o,S,_){{if(He===void 0)try{throw Error()}catch(L){var T=L.stack.trim().match(/\n( *(at )?)/);He=T&&T[1]||""}return`
|
|
18
18
|
`+He+o}}var Le=!1,Ee;{var Ne=typeof WeakMap=="function"?WeakMap:Map;Ee=new Ne}function Jt(o,S){if(!o||Le)return"";{var _=Ee.get(o);if(_!==void 0)return _}var T;Le=!0;var L=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $;$=fe.current,fe.current=null,pe();try{if(S){var R=function(){throw Error()};if(Object.defineProperty(R.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(R,[])}catch(ge){T=ge}Reflect.construct(o,[],R)}else{try{R.call()}catch(ge){T=ge}o.call(R.prototype)}}else{try{throw Error()}catch(ge){T=ge}o()}}catch(ge){if(ge&&T&&typeof ge.stack=="string"){for(var I=ge.stack.split(`
|
|
19
19
|
`),te=T.stack.split(`
|
|
20
20
|
`),U=I.length-1,H=te.length-1;U>=1&&H>=0&&I[U]!==te[H];)H--;for(;U>=1&&H>=0;U--,H--)if(I[U]!==te[H]){if(U!==1||H!==1)do if(U--,H--,H<0||I[U]!==te[H]){var ae=`
|
|
@@ -24,11 +24,11 @@ Check the render method of \``+o+"`."}return""}}function na(o){{if(o!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+S+":"+_+"."}return""}}var un={};function ra(o){{var S=ln();if(!S){var _=typeof o=="string"?o:o.displayName||o.name;_&&(S=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+_+">.")}return S}}function cn(o,S){{if(!o._store||o._store.validated||o.key!=null)return;o._store.validated=!0;var _=ra(S);if(un[_])return;un[_]=!0;var T="";o&&o._owner&&o._owner!==ht.current&&(T=" It was passed a child from "+G(o._owner.type)+"."),$e(o),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',_,T),$e(null)}}function dn(o,S){{if(typeof o!="object")return;if(ft(o))for(var _=0;_<o.length;_++){var T=o[_];bt(T)&&cn(T,S)}else if(bt(o))o._store&&(o._store.validated=!0);else if(o){var L=w(o);if(typeof L=="function"&&L!==o.entries)for(var $=L.call(o),R;!(R=$.next()).done;)bt(R.value)&&cn(R.value,S)}}}function aa(o){{var S=o.type;if(S==null||typeof S=="string")return;var _;if(typeof S=="function")_=S.propTypes;else if(typeof S=="object"&&(S.$$typeof===p||S.$$typeof===c))_=S.propTypes;else return;if(_){var T=G(S);qr(_,o.props,"prop",T,o)}else if(S.PropTypes!==void 0&&!mt){mt=!0;var L=G(S);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",L||"Unknown")}typeof S.getDefaultProps=="function"&&!S.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ia(o){{for(var S=Object.keys(o.props),_=0;_<S.length;_++){var T=S[_];if(T!=="children"&&T!=="key"){$e(o),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",T),$e(null);break}}o.ref!==null&&($e(o),x("Invalid attribute `ref` supplied to `React.Fragment`."),$e(null))}}function pn(o,S,_,T,L,$){{var R=J(o);if(!R){var I="";(o===void 0||typeof o=="object"&&o!==null&&Object.keys(o).length===0)&&(I+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var te=na(L);te?I+=te:I+=ln();var U;o===null?U="null":ft(o)?U="array":o!==void 0&&o.$$typeof===t?(U="<"+(G(o.type)||"Unknown")+" />",I=" Did you accidentally export a JSX literal instead of a component?"):U=typeof o,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",U,I)}var H=ta(o,S,_,L,$);if(H==null)return H;if(R){var ae=S.children;if(ae!==void 0)if(T)if(ft(ae)){for(var Fe=0;Fe<ae.length;Fe++)dn(ae[Fe],o);Object.freeze&&Object.freeze(ae)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else dn(ae,o)}return o===r?ia(H):aa(H),H}}function sa(o,S,_){return pn(o,S,_,!0)}function oa(o,S,_){return pn(o,S,_,!1)}var la=oa,ua=sa;ze.Fragment=r,ze.jsx=la,ze.jsxs=ua}()),ze}process.env.NODE_ENV==="production"?it.exports=yn():it.exports=Sn();var a=it.exports;function xn(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i!="authentication"&&e[i])n.push(t[r]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const s=Object.keys(e[i]).sort();for(let l=0;l<s.length;l++){const d=s[l];d!="sign"&&e[i][d]&&n.push(s[l]+"="+(typeof e[i][d]=="object"?JSON.stringify(e[i][d]):e[i][d]))}}}return n.sort().join("&")}function wn(e,t){let n=xn(e);return n+="&key="+t,vn.MD5(n).toString().toUpperCase()}class St{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:wn({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}}getRequest(t,n){return(r,i,s,l)=>{const d=this.buildHeader(s),p=this.buildAxiosConfig(t,r,i,s,d,n);return hn(p).then(g=>l?g:g.data).catch(g=>Promise.reject(g))}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,n,r,i,s,l){const d={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?r:i.params,headers:s,signal:l};return["POST","PUT"].includes(t)&&(d.data=i.string?JSON.stringify(r):r,d.data.authentication=this.getAuthentication(d.data)),d}buildHeader(t){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...t.headers}}}class xt{constructor(t){this.implementation=t}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const Me=new St,wt=new xt(Me),z=wt;function Ae(e){Me.baseURL!==e.apiBaseURL&&(Me.baseURL=e.apiBaseURL),e.app_id&&(Me.app_id=e.app_id),e.app_secret&&(Me.app_secret=e.app_secret)}const En={login:async(e,t)=>{const n={name:e,password:t};return await z.post()("/account/login",n,{})},list:async()=>await z.post()("/account/list",{filter:{},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),get:async()=>await z.get()("/account/get",{},{}),update:async(e,t)=>{const n={name:e.trim(),email:t.trim()};return await z.put()("/account/update",n,{})},changepassword:async(e,t)=>{const n={old_password:e.trim(),new_password:t.trim()};return await z.post()("/account/changepassword",n,{})},create:async(e,t,n,r)=>await z.post()("/account/create",{name:e.trim(),email:t.trim(),password:n.trim(),role_id:r},{}),edit:async e=>(e.reset_password||(e.new_password=void 0),await z.put()("/account/edit",e,{})),delete:async e=>{if(e)return z.post()("/account/delete",{id:e},{})}},_n={list:async()=>await z.post()("/api/key/list",{filter:{search:""},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(e,t)=>z.post()("/api/key/create",{name:e,role_id:t},{}),delete:async e=>{if(e)return z.post()("/api/key/delete",{id:e},{})}},An={list:async()=>await z.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(e,t,n)=>await z.post()("/datasource/create",{type:e,key:t,config:n},{}),update:async(e,t)=>await z.put()("/datasource/update",{id:e,config:t},{}),delete:async e=>{await z.post()("/datasource/delete",{id:e},{})}},Tn={list:async()=>await z.get()("/role/list",{},{})};var Et=60,_t=Et*60,At=_t*24,kn=At*7,Te=1e3,st=Et*Te,Tt=_t*Te,jn=At*Te,Cn=kn*Te,ot="millisecond",ke="second",je="minute",Ce="hour",me="day",We="week",se="month",kt="quarter",be="year",Oe="date",On="YYYY-MM-DDTHH:mm:ssZ",jt="Invalid Date",In=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Dn=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;const Rn={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var n=["th","st","nd","rd"],r=t%100;return"["+t+(n[(r-20)%10]||n[r]||n[0])+"]"}};var lt=function(t,n,r){var i=String(t);return!i||i.length>=n?t:""+Array(n+1-i.length).join(r)+t},Ln=function(t){var n=-t.utcOffset(),r=Math.abs(n),i=Math.floor(r/60),s=r%60;return(n<=0?"+":"-")+lt(i,2,"0")+":"+lt(s,2,"0")},Nn=function e(t,n){if(t.date()<n.date())return-e(n,t);var r=(n.year()-t.year())*12+(n.month()-t.month()),i=t.clone().add(r,se),s=n-i<0,l=t.clone().add(r+(s?-1:1),se);return+(-(r+(n-i)/(s?i-l:l-i))||0)},$n=function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},Fn=function(t){var n={M:se,y:be,w:We,d:me,D:Oe,h:Ce,m:je,s:ke,ms:ot,Q:kt};return n[t]||String(t||"").toLowerCase().replace(/s$/,"")},Pn=function(t){return t===void 0};const Bn={s:lt,z:Ln,m:Nn,a:$n,p:Fn,u:Pn};var Ge="en",xe={};xe[Ge]=Rn;var ut=function(t){return t instanceof Ze},Ke=function e(t,n,r){var i;if(!t)return Ge;if(typeof t=="string"){var s=t.toLowerCase();xe[s]&&(i=s),n&&(xe[s]=n,i=s);var l=t.split("-");if(!i&&l.length>1)return e(l[0])}else{var d=t.name;xe[d]=t,i=d}return!r&&i&&(Ge=i),i||!r&&Ge},V=function(t,n){if(ut(t))return t.clone();var r=typeof n=="object"?n:{};return r.date=t,r.args=arguments,new Ze(r)},zn=function(t,n){return V(t,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})},N=Bn;N.l=Ke,N.i=ut,N.w=zn;var Mn=function(t){var n=t.date,r=t.utc;if(n===null)return new Date(NaN);if(N.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var i=n.match(In);if(i){var s=i[2]-1||0,l=(i[7]||"0").substring(0,3);return r?new Date(Date.UTC(i[1],s,i[3]||1,i[4]||0,i[5]||0,i[6]||0,l)):new Date(i[1],s,i[3]||1,i[4]||0,i[5]||0,i[6]||0,l)}}return new Date(n)},Ze=function(){function e(n){this.$L=Ke(n.locale,null,!0),this.parse(n)}var t=e.prototype;return t.parse=function(r){this.$d=Mn(r),this.$x=r.x||{},this.init()},t.init=function(){var r=this.$d;this.$y=r.getFullYear(),this.$M=r.getMonth(),this.$D=r.getDate(),this.$W=r.getDay(),this.$H=r.getHours(),this.$m=r.getMinutes(),this.$s=r.getSeconds(),this.$ms=r.getMilliseconds()},t.$utils=function(){return N},t.isValid=function(){return this.$d.toString()!==jt},t.isSame=function(r,i){var s=V(r);return this.startOf(i)<=s&&s<=this.endOf(i)},t.isAfter=function(r,i){return V(r)<this.startOf(i)},t.isBefore=function(r,i){return this.endOf(i)<V(r)},t.$g=function(r,i,s){return N.u(r)?this[i]:this.set(s,r)},t.unix=function(){return Math.floor(this.valueOf()/1e3)},t.valueOf=function(){return this.$d.getTime()},t.startOf=function(r,i){var s=this,l=N.u(i)?!0:i,d=N.p(r),p=function(E,x){var A=N.w(s.$u?Date.UTC(s.$y,x,E):new Date(s.$y,x,E),s);return l?A:A.endOf(me)},g=function(E,x){var A=[0,0,0,0],O=[23,59,59,999];return N.w(s.toDate()[E].apply(s.toDate("s"),(l?A:O).slice(x)),s)},m=this.$W,c=this.$M,u=this.$D,h="set"+(this.$u?"UTC":"");switch(d){case be:return l?p(1,0):p(31,11);case se:return l?p(1,c):p(0,c+1);case We:{var y=this.$locale().weekStart||0,b=(m<y?m+7:m)-y;return p(l?u-b:u+(6-b),c)}case me:case Oe:return g(h+"Hours",0);case Ce:return g(h+"Minutes",1);case je:return g(h+"Seconds",2);case ke:return g(h+"Milliseconds",3);default:return this.clone()}},t.endOf=function(r){return this.startOf(r,!1)},t.$set=function(r,i){var s,l=N.p(r),d="set"+(this.$u?"UTC":""),p=(s={},s[me]=d+"Date",s[Oe]=d+"Date",s[se]=d+"Month",s[be]=d+"FullYear",s[Ce]=d+"Hours",s[je]=d+"Minutes",s[ke]=d+"Seconds",s[ot]=d+"Milliseconds",s)[l],g=l===me?this.$D+(i-this.$W):i;if(l===se||l===be){var m=this.clone().set(Oe,1);m.$d[p](g),m.init(),this.$d=m.set(Oe,Math.min(this.$D,m.daysInMonth())).$d}else p&&this.$d[p](g);return this.init(),this},t.set=function(r,i){return this.clone().$set(r,i)},t.get=function(r){return this[N.p(r)]()},t.add=function(r,i){var s=this,l;r=Number(r);var d=N.p(i),p=function(u){var h=V(s);return N.w(h.date(h.date()+Math.round(u*r)),s)};if(d===se)return this.set(se,this.$M+r);if(d===be)return this.set(be,this.$y+r);if(d===me)return p(1);if(d===We)return p(7);var g=(l={},l[je]=st,l[Ce]=Tt,l[ke]=Te,l)[d]||1,m=this.$d.getTime()+r*g;return N.w(m,this)},t.subtract=function(r,i){return this.add(r*-1,i)},t.format=function(r){var i=this,s=this.$locale();if(!this.isValid())return s.invalidDate||jt;var l=r||On,d=N.z(this),p=this.$H,g=this.$m,m=this.$M,c=s.weekdays,u=s.months,h=s.meridiem,y=function(A,O,q,X){return A&&(A[O]||A(i,l))||q[O].slice(0,X)},b=function(A){return N.s(p%12||12,A,"0")},w=h||function(x,A,O){var q=x<12?"AM":"PM";return O?q.toLowerCase():q},E=function(A){switch(A){case"YY":return String(i.$y).slice(-2);case"YYYY":return N.s(i.$y,4,"0");case"M":return m+1;case"MM":return N.s(m+1,2,"0");case"MMM":return y(s.monthsShort,m,u,3);case"MMMM":return y(u,m);case"D":return i.$D;case"DD":return N.s(i.$D,2,"0");case"d":return String(i.$W);case"dd":return y(s.weekdaysMin,i.$W,c,2);case"ddd":return y(s.weekdaysShort,i.$W,c,3);case"dddd":return c[i.$W];case"H":return String(p);case"HH":return N.s(p,2,"0");case"h":return b(1);case"hh":return b(2);case"a":return w(p,g,!0);case"A":return w(p,g,!1);case"m":return String(g);case"mm":return N.s(g,2,"0");case"s":return String(i.$s);case"ss":return N.s(i.$s,2,"0");case"SSS":return N.s(i.$ms,3,"0");case"Z":return d}return null};return l.replace(Dn,function(x,A){return A||E(x)||d.replace(":","")})},t.utcOffset=function(){return-Math.round(this.$d.getTimezoneOffset()/15)*15},t.diff=function(r,i,s){var l=this,d=N.p(i),p=V(r),g=(p.utcOffset()-this.utcOffset())*st,m=this-p,c=function(){return N.m(l,p)},u;switch(d){case be:u=c()/12;break;case se:u=c();break;case kt:u=c()/3;break;case We:u=(m-g)/Cn;break;case me:u=(m-g)/jn;break;case Ce:u=m/Tt;break;case je:u=m/st;break;case ke:u=m/Te;break;default:u=m;break}return s?u:N.a(u)},t.daysInMonth=function(){return this.endOf(se).$D},t.$locale=function(){return xe[this.$L]},t.locale=function(r,i){if(!r)return this.$L;var s=this.clone(),l=Ke(r,i,!0);return l&&(s.$L=l),s},t.clone=function(){return N.w(this.$d,this)},t.toDate=function(){return new Date(this.valueOf())},t.toJSON=function(){return this.isValid()?this.toISOString():null},t.toISOString=function(){return this.$d.toISOString()},t.toString=function(){return this.$d.toUTCString()},e}(),Ct=Ze.prototype;V.prototype=Ct,[["$ms",ot],["$s",ke],["$m",je],["$H",Ce],["$W",me],["$M",se],["$y",be],["$D",Oe]].forEach(function(e){Ct[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),V.extend=function(e,t){return e.$i||(e(t,Ze,V),e.$i=!0),V},V.locale=Ke,V.isDayjs=ut,V.unix=function(e){return V(e*1e3)},V.en=xe[Ge],V.Ls=xe,V.p={};const W={datasource:An,account:En,role:Tn,api_key:_n,sql_snippet:{list:async({pagination:e},t)=>{const n=await z.post(t)("/sql_snippet/list",{sort:[{field:"update_time",order:"DESC"}],pagination:e},{});return n.data.forEach(r=>{r.create_time=V(r.create_time).format("YYYY-MM-DD HH:mm:ss"),r.update_time=V(r.update_time).format("YYYY-MM-DD HH:mm:ss")}),n},get:async(e,t)=>await z.post(t)("/sql_snippet/get",{id:e},{}),create:async(e,t)=>await z.post(t)("/sql_snippet/create",e,{}),update:async(e,t)=>await z.put(t)("/sql_snippet/update",e,{}),delete:async(e,t)=>z.post(t)("/sql_snippet/delete",{id:e},{})}},oe={size:"sm",spacing:"md",button:{size:"xs"}};function Gn({submit:e,styles:t=oe,type:n}){const{control:r,setValue:i,handleSubmit:s}=j.useForm({defaultValues:{type:n,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return k.useEffect(()=>{i("type",n)},[i,n]),a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:s(e),children:[a.jsx(j.Controller,{name:"key",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...l})}),a.jsx(f.Divider,{label:"Connection Info",labelPosition:"center"}),a.jsxs(f.Group,{grow:!0,children:[a.jsx(j.Controller,{name:"config.host",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Host",sx:{flexGrow:1},...l})}),a.jsx(j.Controller,{name:"config.port",control:r,render:({field:l})=>a.jsx(f.NumberInput,{mb:t.spacing,size:t.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...l})})]}),a.jsx(j.Controller,{name:"config.username",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...l})}),a.jsx(j.Controller,{name:"config.password",control:r,render:({field:l})=>a.jsx(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...l})}),a.jsx(j.Controller,{name:"config.database",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Database",...l})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}const Un=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return a.jsx(f.Box,{sx:{position:"relative"},children:a.jsx(Pe,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Xe=k.forwardRef(({value:e,onChange:t,label:n,modalTitle:r,defaultValue:i,styles:s},l)=>{const[d,{setTrue:p,setFalse:g}]=he.useBoolean(),[m,c]=k.useState(e),u=()=>{g(),t(m)},h=()=>{g(),c(e)},y=()=>{c(i)};return k.useEffect(()=>{c(e)},[e]),a.jsxs(a.Fragment,{children:[a.jsx(f.Button,{variant:"filled",size:s.button.size,onClick:p,sx:{flexGrow:1},children:n}),a.jsx(f.Modal,{size:800,title:r,opened:d,onClose:g,closeOnClickOutside:!1,withCloseButton:!1,children:d&&a.jsxs(f.Stack,{children:[a.jsx(Un,{value:m,onChange:c}),a.jsxs(f.Group,{position:"apart",children:[a.jsx(f.Button,{onClick:y,color:"red",leftIcon:a.jsx(ie.Recycle,{size:20}),children:"Reset"}),a.jsxs(f.Group,{position:"right",children:[a.jsx(f.Button,{onClick:h,variant:"subtle",children:"Cancel"}),a.jsx(f.Button,{onClick:u,children:"OK"})]})]})]})})]})}),Qe={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
|
|
27
|
+
Check the top-level render call using <`+_+">.")}return S}}function cn(o,S){{if(!o._store||o._store.validated||o.key!=null)return;o._store.validated=!0;var _=ra(S);if(un[_])return;un[_]=!0;var T="";o&&o._owner&&o._owner!==ht.current&&(T=" It was passed a child from "+G(o._owner.type)+"."),$e(o),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',_,T),$e(null)}}function dn(o,S){{if(typeof o!="object")return;if(ft(o))for(var _=0;_<o.length;_++){var T=o[_];bt(T)&&cn(T,S)}else if(bt(o))o._store&&(o._store.validated=!0);else if(o){var L=w(o);if(typeof L=="function"&&L!==o.entries)for(var $=L.call(o),R;!(R=$.next()).done;)bt(R.value)&&cn(R.value,S)}}}function aa(o){{var S=o.type;if(S==null||typeof S=="string")return;var _;if(typeof S=="function")_=S.propTypes;else if(typeof S=="object"&&(S.$$typeof===p||S.$$typeof===c))_=S.propTypes;else return;if(_){var T=G(S);qr(_,o.props,"prop",T,o)}else if(S.PropTypes!==void 0&&!mt){mt=!0;var L=G(S);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",L||"Unknown")}typeof S.getDefaultProps=="function"&&!S.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ia(o){{for(var S=Object.keys(o.props),_=0;_<S.length;_++){var T=S[_];if(T!=="children"&&T!=="key"){$e(o),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",T),$e(null);break}}o.ref!==null&&($e(o),x("Invalid attribute `ref` supplied to `React.Fragment`."),$e(null))}}function pn(o,S,_,T,L,$){{var R=J(o);if(!R){var I="";(o===void 0||typeof o=="object"&&o!==null&&Object.keys(o).length===0)&&(I+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var te=na(L);te?I+=te:I+=ln();var U;o===null?U="null":ft(o)?U="array":o!==void 0&&o.$$typeof===t?(U="<"+(G(o.type)||"Unknown")+" />",I=" Did you accidentally export a JSX literal instead of a component?"):U=typeof o,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",U,I)}var H=ta(o,S,_,L,$);if(H==null)return H;if(R){var ae=S.children;if(ae!==void 0)if(T)if(ft(ae)){for(var Fe=0;Fe<ae.length;Fe++)dn(ae[Fe],o);Object.freeze&&Object.freeze(ae)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else dn(ae,o)}return o===r?ia(H):aa(H),H}}function sa(o,S,_){return pn(o,S,_,!0)}function oa(o,S,_){return pn(o,S,_,!1)}var la=oa,ua=sa;ze.Fragment=r,ze.jsx=la,ze.jsxs=ua}()),ze}process.env.NODE_ENV==="production"?it.exports=yn():it.exports=Sn();var a=it.exports;function xn(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i!="authentication"&&e[i])n.push(t[r]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const s=Object.keys(e[i]).sort();for(let l=0;l<s.length;l++){const d=s[l];d!="sign"&&e[i][d]&&n.push(s[l]+"="+(typeof e[i][d]=="object"?JSON.stringify(e[i][d]):e[i][d]))}}}return n.sort().join("&")}function wn(e,t){let n=xn(e);return n+="&key="+t,vn.MD5(n).toString().toUpperCase()}class St{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:wn({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}}getRequest(t,n){return(r,i,s,l)=>{const d=this.buildHeader(s),p=this.buildAxiosConfig(t,r,i,s,d,n);return hn(p).then(g=>l?g:g.data).catch(g=>Promise.reject(g))}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,n,r,i,s,l){const d={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?r:i.params,headers:s,signal:l};return["POST","PUT"].includes(t)&&(d.data=i.string?JSON.stringify(r):r,d.data.authentication=this.getAuthentication(d.data)),d}buildHeader(t){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...t.headers}}}class xt{constructor(t){this.implementation=t}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const Me=new St,wt=new xt(Me),z=wt;function Ae(e){Me.baseURL!==e.apiBaseURL&&(Me.baseURL=e.apiBaseURL),e.app_id&&(Me.app_id=e.app_id),e.app_secret&&(Me.app_secret=e.app_secret)}const En={login:async(e,t)=>{const n={name:e,password:t};return await z.post()("/account/login",n,{})},list:async()=>await z.post()("/account/list",{filter:{},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),get:async()=>await z.get()("/account/get",{},{}),update:async(e,t)=>{const n={name:e.trim(),email:t.trim()};return await z.put()("/account/update",n,{})},changepassword:async(e,t)=>{const n={old_password:e.trim(),new_password:t.trim()};return await z.post()("/account/changepassword",n,{})},create:async(e,t,n,r)=>await z.post()("/account/create",{name:e.trim(),email:t.trim(),password:n.trim(),role_id:r},{}),edit:async e=>(e.reset_password||(e.new_password=void 0),await z.put()("/account/edit",e,{})),delete:async e=>{if(e)return z.post()("/account/delete",{id:e},{})}},_n={list:async()=>await z.post()("/api/key/list",{filter:{search:""},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(e,t)=>z.post()("/api/key/create",{name:e,role_id:t},{}),delete:async e=>{if(e)return z.post()("/api/key/delete",{id:e},{})}},An={list:async()=>await z.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(e,t,n)=>await z.post()("/datasource/create",{type:e,key:t,config:n},{}),update:async(e,t)=>await z.put()("/datasource/update",{id:e,config:t},{}),delete:async e=>{await z.post()("/datasource/delete",{id:e},{})}},Tn={list:async()=>await z.get()("/role/list",{},{})};var Et=60,_t=Et*60,At=_t*24,Cn=At*7,Te=1e3,st=Et*Te,Tt=_t*Te,kn=At*Te,jn=Cn*Te,ot="millisecond",Ce="second",ke="minute",je="hour",me="day",We="week",se="month",Ct="quarter",be="year",Oe="date",On="YYYY-MM-DDTHH:mm:ssZ",kt="Invalid Date",In=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Dn=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;const Rn={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var n=["th","st","nd","rd"],r=t%100;return"["+t+(n[(r-20)%10]||n[r]||n[0])+"]"}};var lt=function(t,n,r){var i=String(t);return!i||i.length>=n?t:""+Array(n+1-i.length).join(r)+t},Ln=function(t){var n=-t.utcOffset(),r=Math.abs(n),i=Math.floor(r/60),s=r%60;return(n<=0?"+":"-")+lt(i,2,"0")+":"+lt(s,2,"0")},Nn=function e(t,n){if(t.date()<n.date())return-e(n,t);var r=(n.year()-t.year())*12+(n.month()-t.month()),i=t.clone().add(r,se),s=n-i<0,l=t.clone().add(r+(s?-1:1),se);return+(-(r+(n-i)/(s?i-l:l-i))||0)},$n=function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},Fn=function(t){var n={M:se,y:be,w:We,d:me,D:Oe,h:je,m:ke,s:Ce,ms:ot,Q:Ct};return n[t]||String(t||"").toLowerCase().replace(/s$/,"")},Pn=function(t){return t===void 0};const Bn={s:lt,z:Ln,m:Nn,a:$n,p:Fn,u:Pn};var Ge="en",xe={};xe[Ge]=Rn;var ut=function(t){return t instanceof Ze},Ke=function e(t,n,r){var i;if(!t)return Ge;if(typeof t=="string"){var s=t.toLowerCase();xe[s]&&(i=s),n&&(xe[s]=n,i=s);var l=t.split("-");if(!i&&l.length>1)return e(l[0])}else{var d=t.name;xe[d]=t,i=d}return!r&&i&&(Ge=i),i||!r&&Ge},V=function(t,n){if(ut(t))return t.clone();var r=typeof n=="object"?n:{};return r.date=t,r.args=arguments,new Ze(r)},zn=function(t,n){return V(t,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})},N=Bn;N.l=Ke,N.i=ut,N.w=zn;var Mn=function(t){var n=t.date,r=t.utc;if(n===null)return new Date(NaN);if(N.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var i=n.match(In);if(i){var s=i[2]-1||0,l=(i[7]||"0").substring(0,3);return r?new Date(Date.UTC(i[1],s,i[3]||1,i[4]||0,i[5]||0,i[6]||0,l)):new Date(i[1],s,i[3]||1,i[4]||0,i[5]||0,i[6]||0,l)}}return new Date(n)},Ze=function(){function e(n){this.$L=Ke(n.locale,null,!0),this.parse(n)}var t=e.prototype;return t.parse=function(r){this.$d=Mn(r),this.$x=r.x||{},this.init()},t.init=function(){var r=this.$d;this.$y=r.getFullYear(),this.$M=r.getMonth(),this.$D=r.getDate(),this.$W=r.getDay(),this.$H=r.getHours(),this.$m=r.getMinutes(),this.$s=r.getSeconds(),this.$ms=r.getMilliseconds()},t.$utils=function(){return N},t.isValid=function(){return this.$d.toString()!==kt},t.isSame=function(r,i){var s=V(r);return this.startOf(i)<=s&&s<=this.endOf(i)},t.isAfter=function(r,i){return V(r)<this.startOf(i)},t.isBefore=function(r,i){return this.endOf(i)<V(r)},t.$g=function(r,i,s){return N.u(r)?this[i]:this.set(s,r)},t.unix=function(){return Math.floor(this.valueOf()/1e3)},t.valueOf=function(){return this.$d.getTime()},t.startOf=function(r,i){var s=this,l=N.u(i)?!0:i,d=N.p(r),p=function(E,x){var A=N.w(s.$u?Date.UTC(s.$y,x,E):new Date(s.$y,x,E),s);return l?A:A.endOf(me)},g=function(E,x){var A=[0,0,0,0],O=[23,59,59,999];return N.w(s.toDate()[E].apply(s.toDate("s"),(l?A:O).slice(x)),s)},m=this.$W,c=this.$M,u=this.$D,h="set"+(this.$u?"UTC":"");switch(d){case be:return l?p(1,0):p(31,11);case se:return l?p(1,c):p(0,c+1);case We:{var y=this.$locale().weekStart||0,b=(m<y?m+7:m)-y;return p(l?u-b:u+(6-b),c)}case me:case Oe:return g(h+"Hours",0);case je:return g(h+"Minutes",1);case ke:return g(h+"Seconds",2);case Ce:return g(h+"Milliseconds",3);default:return this.clone()}},t.endOf=function(r){return this.startOf(r,!1)},t.$set=function(r,i){var s,l=N.p(r),d="set"+(this.$u?"UTC":""),p=(s={},s[me]=d+"Date",s[Oe]=d+"Date",s[se]=d+"Month",s[be]=d+"FullYear",s[je]=d+"Hours",s[ke]=d+"Minutes",s[Ce]=d+"Seconds",s[ot]=d+"Milliseconds",s)[l],g=l===me?this.$D+(i-this.$W):i;if(l===se||l===be){var m=this.clone().set(Oe,1);m.$d[p](g),m.init(),this.$d=m.set(Oe,Math.min(this.$D,m.daysInMonth())).$d}else p&&this.$d[p](g);return this.init(),this},t.set=function(r,i){return this.clone().$set(r,i)},t.get=function(r){return this[N.p(r)]()},t.add=function(r,i){var s=this,l;r=Number(r);var d=N.p(i),p=function(u){var h=V(s);return N.w(h.date(h.date()+Math.round(u*r)),s)};if(d===se)return this.set(se,this.$M+r);if(d===be)return this.set(be,this.$y+r);if(d===me)return p(1);if(d===We)return p(7);var g=(l={},l[ke]=st,l[je]=Tt,l[Ce]=Te,l)[d]||1,m=this.$d.getTime()+r*g;return N.w(m,this)},t.subtract=function(r,i){return this.add(r*-1,i)},t.format=function(r){var i=this,s=this.$locale();if(!this.isValid())return s.invalidDate||kt;var l=r||On,d=N.z(this),p=this.$H,g=this.$m,m=this.$M,c=s.weekdays,u=s.months,h=s.meridiem,y=function(A,O,q,X){return A&&(A[O]||A(i,l))||q[O].slice(0,X)},b=function(A){return N.s(p%12||12,A,"0")},w=h||function(x,A,O){var q=x<12?"AM":"PM";return O?q.toLowerCase():q},E=function(A){switch(A){case"YY":return String(i.$y).slice(-2);case"YYYY":return N.s(i.$y,4,"0");case"M":return m+1;case"MM":return N.s(m+1,2,"0");case"MMM":return y(s.monthsShort,m,u,3);case"MMMM":return y(u,m);case"D":return i.$D;case"DD":return N.s(i.$D,2,"0");case"d":return String(i.$W);case"dd":return y(s.weekdaysMin,i.$W,c,2);case"ddd":return y(s.weekdaysShort,i.$W,c,3);case"dddd":return c[i.$W];case"H":return String(p);case"HH":return N.s(p,2,"0");case"h":return b(1);case"hh":return b(2);case"a":return w(p,g,!0);case"A":return w(p,g,!1);case"m":return String(g);case"mm":return N.s(g,2,"0");case"s":return String(i.$s);case"ss":return N.s(i.$s,2,"0");case"SSS":return N.s(i.$ms,3,"0");case"Z":return d}return null};return l.replace(Dn,function(x,A){return A||E(x)||d.replace(":","")})},t.utcOffset=function(){return-Math.round(this.$d.getTimezoneOffset()/15)*15},t.diff=function(r,i,s){var l=this,d=N.p(i),p=V(r),g=(p.utcOffset()-this.utcOffset())*st,m=this-p,c=function(){return N.m(l,p)},u;switch(d){case be:u=c()/12;break;case se:u=c();break;case Ct:u=c()/3;break;case We:u=(m-g)/jn;break;case me:u=(m-g)/kn;break;case je:u=m/Tt;break;case ke:u=m/st;break;case Ce:u=m/Te;break;default:u=m;break}return s?u:N.a(u)},t.daysInMonth=function(){return this.endOf(se).$D},t.$locale=function(){return xe[this.$L]},t.locale=function(r,i){if(!r)return this.$L;var s=this.clone(),l=Ke(r,i,!0);return l&&(s.$L=l),s},t.clone=function(){return N.w(this.$d,this)},t.toDate=function(){return new Date(this.valueOf())},t.toJSON=function(){return this.isValid()?this.toISOString():null},t.toISOString=function(){return this.$d.toISOString()},t.toString=function(){return this.$d.toUTCString()},e}(),jt=Ze.prototype;V.prototype=jt,[["$ms",ot],["$s",Ce],["$m",ke],["$H",je],["$W",me],["$M",se],["$y",be],["$D",Oe]].forEach(function(e){jt[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),V.extend=function(e,t){return e.$i||(e(t,Ze,V),e.$i=!0),V},V.locale=Ke,V.isDayjs=ut,V.unix=function(e){return V(e*1e3)},V.en=xe[Ge],V.Ls=xe,V.p={};const W={datasource:An,account:En,role:Tn,api_key:_n,sql_snippet:{list:async({pagination:e},t)=>{const n=await z.post(t)("/sql_snippet/list",{sort:[{field:"update_time",order:"DESC"}],pagination:e},{});return n.data.forEach(r=>{r.create_time=V(r.create_time).format("YYYY-MM-DD HH:mm:ss"),r.update_time=V(r.update_time).format("YYYY-MM-DD HH:mm:ss")}),n},get:async(e,t)=>await z.post(t)("/sql_snippet/get",{id:e},{}),create:async(e,t)=>await z.post(t)("/sql_snippet/create",e,{}),update:async(e,t)=>await z.put(t)("/sql_snippet/update",e,{}),delete:async(e,t)=>z.post(t)("/sql_snippet/delete",{id:e},{})}},oe={size:"sm",spacing:"md",button:{size:"xs"}};function Gn({submit:e,styles:t=oe,type:n}){const{control:r,setValue:i,handleSubmit:s}=k.useForm({defaultValues:{type:n,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return C.useEffect(()=>{i("type",n)},[i,n]),a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:s(e),children:[a.jsx(k.Controller,{name:"key",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...l})}),a.jsx(f.Divider,{label:"Connection Info",labelPosition:"center"}),a.jsxs(f.Group,{grow:!0,children:[a.jsx(k.Controller,{name:"config.host",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Host",sx:{flexGrow:1},...l})}),a.jsx(k.Controller,{name:"config.port",control:r,render:({field:l})=>a.jsx(f.NumberInput,{mb:t.spacing,size:t.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...l})})]}),a.jsx(k.Controller,{name:"config.username",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...l})}),a.jsx(k.Controller,{name:"config.password",control:r,render:({field:l})=>a.jsx(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...l})}),a.jsx(k.Controller,{name:"config.database",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Database",...l})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}const Un=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return a.jsx(f.Box,{sx:{position:"relative"},children:a.jsx(Pe,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Xe=C.forwardRef(({value:e,onChange:t,label:n,modalTitle:r,defaultValue:i,styles:s},l)=>{const[d,{setTrue:p,setFalse:g}]=he.useBoolean(),[m,c]=C.useState(e),u=()=>{g(),t(m)},h=()=>{g(),c(e)},y=()=>{c(i)};return C.useEffect(()=>{c(e)},[e]),a.jsxs(a.Fragment,{children:[a.jsx(f.Button,{variant:"filled",size:s.button.size,onClick:p,sx:{flexGrow:1},children:n}),a.jsx(f.Modal,{size:800,title:r,opened:d,onClose:g,closeOnClickOutside:!1,withCloseButton:!1,children:d&&a.jsxs(f.Stack,{children:[a.jsx(Un,{value:m,onChange:c}),a.jsxs(f.Group,{position:"apart",children:[a.jsx(f.Button,{onClick:y,color:"red",leftIcon:a.jsx(ie.Recycle,{size:20}),children:"Reset"}),a.jsxs(f.Group,{position:"right",children:[a.jsx(f.Button,{onClick:h,variant:"subtle",children:"Cancel"}),a.jsx(f.Button,{onClick:u,children:"OK"})]})]})]})})]})}),Qe={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
|
|
28
28
|
`),post:["function post_process(res, utils) {"," // your code goes here"," return data","}"].join(`
|
|
29
|
-
`)};function qn({submit:e,styles:t=oe}){const{control:n,setValue:r,handleSubmit:i}=
|
|
29
|
+
`)};function qn({submit:e,styles:t=oe}){const{control:n,setValue:r,handleSubmit:i}=k.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:Qe.pre,post:Qe.post}}}});return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:i(e),children:[a.jsx(k.Controller,{name:"key",control:n,render:({field:s})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...s})}),a.jsx(f.Divider,{label:"Connection Info",labelPosition:"center"}),a.jsx(k.Controller,{name:"config.host",control:n,render:({field:s})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,label:"Base URL",sx:{flexGrow:1},...s})}),a.jsxs(f.Group,{grow:!0,children:[a.jsx(k.Controller,{name:"config.processing.pre",control:n,render:({field:s})=>a.jsx(Xe,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:Qe.pre,...s,styles:t})}),a.jsx(k.Controller,{name:"config.processing.post",control:n,render:({field:s})=>a.jsx(Xe,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:Qe.post,...s,styles:t})})]}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Yn({styles:e=oe}){return a.jsx(f.Box,{mx:"auto",children:a.jsxs(f.Alert,{mt:e.spacing,icon:a.jsx(ie.AlertCircle,{size:16}),children:["Only ",a.jsx("b",{children:"SELECT"})," privilege is needed."]})})}function Hn({postSubmit:e,styles:t=oe}){const[n,r]=C.useState("postgresql"),i=async({type:d,key:p,config:g})=>{D.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0,autoClose:!1});try{console.log({type:d,key:p,config:g}),await W.datasource.create(d,p,g),D.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green",autoClose:!0}),e()}catch(m){console.error(m),D.updateNotification({id:"for-creating",title:"Failed",message:m.message,color:"red",autoClose:!0})}},s=n==="postgresql"||n==="mysql",l=n==="http";return a.jsxs(f.Box,{mx:"auto",children:[a.jsx(f.SegmentedControl,{fullWidth:!0,mb:t.spacing,size:t.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:n,onChange:d=>r(d)}),s&&a.jsx(Yn,{styles:t}),s&&a.jsx(Gn,{submit:i,styles:t,type:n}),l&&a.jsx(qn,{submit:i,styles:t})]})}function Ot({onSuccess:e,styles:t=oe}){const[n,r]=C.useState(!1),i=()=>r(!0),s=()=>r(!1),l=()=>{e(),s()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:n,onClose:()=>r(!1),title:"Add a data source",trapFocus:!0,onDragStart:d=>{d.stopPropagation()},children:a.jsx(Hn,{postSubmit:l,styles:t})}),a.jsx(f.Button,{size:t.button.size,onClick:i,leftIcon:a.jsx(ie.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}const Vn=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function Wn(e){C.useEffect(()=>{if(Pe.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/settings-form");const n=Vn(e);Pe.loader.config({paths:{vs:n}}),Pe.loader.init().then(r=>console.log("monaco instance:",r))},[])}function It({id:e,name:t,isProtected:n,onSuccess:r,styles:i=oe}){const s=_e.useModals(),l=async()=>{e&&(D.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0,autoClose:!1}),await W.datasource.delete(e),D.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${t}] is deleted`,color:"green",autoClose:!0}),r())},d=()=>s.openConfirmModal({title:"Delete this data source?",children:a.jsx(f.Text,{size:i.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:l});return n?a.jsx(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:a.jsx(f.Button,{size:i.button.size,color:"gray",variant:"light",leftIcon:a.jsx(ce.IconLock,{size:16}),sx:{transform:"none !important"},children:"Delete"})}):a.jsx(f.Button,{size:i.button.size,color:"red",onClick:d,leftIcon:a.jsx(ie.Trash,{size:16}),children:"Delete"})}const Dt={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
|
|
30
30
|
`),post:["function post_process(res, utils) {"," // your code goes here"," return data","}"].join(`
|
|
31
|
-
`)};function Kn({name:e,config:t,submit:n,styles:r=oe}){const{control:i,handleSubmit:s}=j.useForm({defaultValues:{config:t}});return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:s(n),children:[a.jsx(f.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Name",value:e,readOnly:!0}),a.jsx(f.Divider,{label:"Connection Info",labelPosition:"center"}),a.jsx(j.Controller,{name:"config.host",control:i,render:({field:l})=>a.jsx(f.TextInput,{mb:r.spacing,size:r.size,label:"Base URL",sx:{flexGrow:1},...l})}),a.jsxs(f.Group,{grow:!0,children:[a.jsx(j.Controller,{name:"config.processing.pre",control:i,render:({field:l})=>a.jsx(Xe,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:Dt.pre,...l,styles:r})}),a.jsx(j.Controller,{name:"config.processing.post",control:i,render:({field:l})=>a.jsx(Xe,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:Dt.post,...l,styles:r})})]}),a.jsx(f.Group,{position:"right",mt:r.spacing,children:a.jsx(f.Button,{type:"submit",size:r.button.size,children:"Save"})})]})})}function Zn({dataSource:e,postSubmit:t,styles:n=oe}){const r=async({config:i})=>{D.showNotification({id:"for-updating",title:"Pending",message:"Editing data source...",loading:!0});try{console.log({config:i}),await W.datasource.update(e.id,i),D.updateNotification({id:"for-updating",title:"Successful",message:"Data source is updated",color:"green"}),t()}catch(s){D.updateNotification({id:"for-updating",title:"Failed",message:s.message,color:"red"})}};return e.config?a.jsx(f.Box,{mx:"auto",children:a.jsx(Kn,{name:e.key,config:e.config,submit:r,styles:n})}):(console.error(new Error("unexpected empty config of a http datasource")),null)}function Xn({dataSource:e,onSuccess:t,styles:n=oe}){const[r,i]=k.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{t(),l()};return e.is_preset?a.jsx(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be changed",children:a.jsx(f.Button,{size:n.button.size,color:"gray",variant:"light",leftIcon:a.jsx(ce.IconLock,{size:16}),sx:{transform:"none !important"},children:"Edit"})}):e.type!=="http"?a.jsx(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"Only HTTP datasources can be edited",children:a.jsx(f.Button,{size:n.button.size,color:"gray",variant:"light",leftIcon:a.jsx(ce.IconEdit,{size:16}),sx:{transform:"none !important"},children:"Edit"})}):a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:"Add a data source",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a.jsx(Zn,{dataSource:e,postSubmit:d,styles:n})}),a.jsx(f.Button,{size:n.button.size,color:"blue",onClick:s,leftIcon:a.jsx(ce.IconEdit,{size:16}),children:"Edit"})]})}const Qn={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL"},Jn={http:a.jsx(ce.IconNetwork,{}),mysql:a.jsx(ce.IconBrandMysql,{}),postgresql:a.jsx(ce.IconDatabase,{})};function er({type:e}){return a.jsxs(f.Group,{children:[a.jsx(f.ActionIcon,{size:"xs",sx:{transform:"none !important"},children:Jn[e]}),a.jsx(f.Text,{sx:{cusor:"default",userSelect:"none"},children:Qn[e]})]})}function tr({styles:e=oe,config:t}){Wn(t.monacoPath),Ae(t);const{data:n=[],loading:r,refresh:i}=he.useRequest(async()=>{const{data:s}=await W.datasource.list();return s},{refreshDeps:[]});return a.jsxs(a.Fragment,{children:[a.jsx(f.Group,{pt:e.spacing,position:"right",children:a.jsx(Ot,{onSuccess:i})}),a.jsxs(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a.jsx(f.LoadingOverlay,{visible:r}),a.jsxs(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Type"}),a.jsx("th",{children:"Name"}),a.jsx("th",{children:"Action"})]})}),a.jsx("tbody",{children:n.map(s=>{const{id:l,key:d,type:p,is_preset:g}=s;return a.jsxs("tr",{children:[a.jsx("td",{width:200,children:a.jsx(er,{type:p})}),a.jsx("td",{children:d}),a.jsx("td",{width:400,children:a.jsxs(f.Group,{position:"left",children:[a.jsx(Xn,{dataSource:s,onSuccess:i,styles:e}),a.jsx(It,{isProtected:g,id:l,name:d,onSuccess:i,styles:e})]})})]},d)})})]})]})]})}const nr=k.forwardRef(({label:e,value:t,description:n,...r},i)=>a.jsxs(f.Stack,{spacing:2,ref:i,...r,children:[a.jsx(f.Text,{size:"sm",children:e}),a.jsx(f.Text,{size:"xs",color:"dimmed",className:"role-description",children:n})]})),ct=k.forwardRef(({styles:e,value:t,onChange:n},r)=>{const{data:i=[],loading:s}=he.useRequest(async()=>(await W.role.list()).map(d=>({label:d.id,value:d.id,description:d.description,disabled:d.id==="SUPERADMIN"})),{refreshDeps:[]});return a.jsx(f.Select,{ref:r,mb:e.spacing,size:e.size,required:!0,label:"Role",itemComponent:nr,data:i,disabled:s,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:n})}),ve={size:"sm",spacing:"md",button:{size:"xs"}};function rr({postSubmit:e,styles:t=ve,initialRoleID:n}){const{control:r,handleSubmit:i}=j.useForm({defaultValues:{name:"",email:"",role_id:n,password:""}}),s=async({name:l,email:d,password:p,role_id:g})=>{try{D.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await W.account.create(l,d,p,g),D.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),e()}catch(m){D.updateNotification({id:"for-creating",title:"Failed",message:m.message,color:"red"})}};return a.jsx(f.Box,{mx:"auto",mb:10,children:a.jsxs("form",{onSubmit:i(s),children:[a.jsx(j.Controller,{name:"name",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...l})}),a.jsx(j.Controller,{name:"email",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Email",...l})}),a.jsx(j.Controller,{name:"password",control:r,render:({field:l})=>a.jsx(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...l})}),a.jsx(j.Controller,{name:"role_id",control:r,render:({field:l})=>a.jsx(ct,{styles:t,...l})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Rt({onSuccess:e,styles:t=ve,initialRoleID:n}){const[r,i]=k.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{e(),l()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:"Add an Account",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a.jsx(rr,{postSubmit:d,styles:t,initialRoleID:n})}),a.jsx(f.Button,{size:t.button.size,onClick:s,leftIcon:a.jsx(ie.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Lt({id:e,name:t,onSuccess:n,styles:r=ve}){const i=_e.useModals(),s=async()=>{if(e){D.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await W.account.delete(e),D.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${t}] is deleted`,color:"green"}),n()}catch(d){D.updateNotification({id:"for-deleting",title:"Failed",message:d.message,color:"red"})}}},l=()=>i.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:s});return a.jsx(f.Button,{size:r.button.size,color:"red",onClick:l,leftIcon:a.jsx(ie.Trash,{size:20}),children:"Delete"})}function ar({id:e,name:t,email:n,role_id:r,postSubmit:i,styles:s=ve}){const{control:l,handleSubmit:d,watch:p}=j.useForm({defaultValues:{name:t,email:n,role_id:r,reset_password:!1,new_password:""}}),g=async({name:u,email:h,role_id:y,reset_password:b,new_password:w})=>{try{D.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await W.account.edit({id:e,name:u.trim(),email:h.trim(),role_id:y,reset_password:b,new_password:w.trim()}),D.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),i()}catch(E){D.updateNotification({id:"for-updating",title:"Failed",message:E.message,color:"red"})}},[m,c]=p(["reset_password","new_password"]);return a.jsx(f.Box,{mx:"auto",mb:10,children:a.jsxs("form",{onSubmit:d(g),children:[a.jsx(j.Controller,{name:"name",control:l,render:({field:u})=>a.jsx(f.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Username",...u})}),a.jsx(j.Controller,{name:"email",control:l,render:({field:u})=>a.jsx(f.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Email",...u})}),a.jsx(j.Controller,{name:"role_id",control:l,render:({field:u})=>a.jsx(ct,{styles:s,...u})}),a.jsx(f.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),a.jsx(j.Controller,{name:"reset_password",control:l,render:({field:u})=>a.jsx(f.Switch,{mb:s.spacing,size:s.size,label:"Reset password",checked:u.value,onChange:h=>u.onChange(h.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),m&&a.jsx(j.Controller,{name:"new_password",control:l,render:({field:u})=>a.jsx(f.PasswordInput,{autoComplete:"off",mb:s.spacing,size:s.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...u})}),a.jsx(f.Group,{position:"right",mt:s.spacing,children:a.jsx(f.Button,{type:"submit",size:s.button.size,children:"Submit"})})]})})}function ir({account:e,onSuccess:t,styles:n=ve}){const[r,i]=k.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{t(),l()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:`Editing ${e.name}`,trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a.jsx(ar,{...e,postSubmit:d,styles:n})}),a.jsx(f.Button,{size:n.button.size,onClick:s,leftIcon:a.jsx(ie.Edit,{size:20}),children:"Edit"})]})}function sr({styles:e=ve,config:t}){var d;Ae(t);const{data:n=[],loading:r,refresh:i}=he.useRequest(async()=>{const{data:p}=await W.account.list();return p},{refreshDeps:[]}),{data:s=[],loading:l}=he.useRequest(async()=>(await W.role.list()).map(g=>({label:g.id,value:g.id,description:g.description,disabled:g.id==="SUPERADMIN"})),{refreshDeps:[]});return a.jsxs(a.Fragment,{children:[a.jsx(f.Group,{pt:e.spacing,position:"right",children:a.jsx(Rt,{onSuccess:i,initialRoleID:((d=s==null?void 0:s[0])==null?void 0:d.value)??"INACTIVE"})}),a.jsxs(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a.jsx(f.LoadingOverlay,{visible:r||l}),a.jsxs(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Username"}),a.jsx("th",{children:"Email"}),a.jsx("th",{children:"Role"}),a.jsx("th",{children:"Action"})]})}),a.jsx("tbody",{children:n.map(p=>{const{id:g,name:m,email:c,role_id:u}=p;return a.jsxs("tr",{children:[a.jsx("td",{width:200,children:m}),a.jsx("td",{width:200,children:c}),a.jsx("td",{width:200,children:u}),a.jsx("td",{width:200,children:a.jsxs(f.Group,{position:"left",children:[a.jsx(ir,{account:p,onSuccess:i}),a.jsx(Lt,{id:g,name:m,onSuccess:i})]})})]},g)})})]})]})]})}function or({postSubmit:e,styles:t=ve}){const{control:n,handleSubmit:r}=j.useForm({defaultValues:{name:"",password:""}}),i=async({name:s,password:l})=>{try{D.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const d=await W.account.login(s.trim(),l.trim());window.localStorage.setItem("token",d.token),D.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),e(d)}catch(d){D.updateNotification({id:"for-login",title:"Login Failed",message:d.message,color:"red"})}};return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:r(i),children:[a.jsx(j.Controller,{name:"name",control:n,render:({field:s})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...s})}),a.jsx(j.Controller,{name:"password",control:n,render:({field:s})=>a.jsx(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...s})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Submit"})})]})})}function lr({styles:e=ve,config:t,onSuccess:n}){return Ae(t),a.jsx(a.Fragment,{children:a.jsx(f.Box,{mt:e.spacing,sx:{position:"relative"},children:a.jsx(or,{styles:e,postSubmit:n})})})}const Je={size:"sm",spacing:"md",button:{size:"xs"}};function ur({postSubmit:e,styles:t=Je,initialRoleID:n}){const{control:r,handleSubmit:i}=j.useForm({defaultValues:{name:"",role_id:n}}),s=async({name:l,role_id:d})=>{try{D.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:p,app_secret:g}=await W.api_key.create(l,d);D.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),e(p,g)}catch(p){D.updateNotification({id:"for-creating",title:"Failed",message:p.message,color:"red"})}};return a.jsx(f.Box,{mx:"auto",mb:10,children:a.jsxs("form",{onSubmit:i(s),children:[a.jsx(j.Controller,{name:"name",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...l})}),a.jsx(j.Controller,{name:"role_id",control:r,render:({field:l})=>a.jsx(ct,{styles:t,...l})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Nt({onSuccess:e,styles:t=Je,initialRoleID:n}){const r=_e.useModals(),[i,s]=k.useState(!1),l=()=>s(!0),d=()=>s(!1),p=(g,m)=>{d(),r.openModal({title:"API Key is generated",children:a.jsxs(f.Stack,{children:[a.jsx(f.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),a.jsx(f.TextInput,{defaultValue:g,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),a.jsx(f.TextInput,{defaultValue:m,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),a.jsx(f.Button,{size:"sm",onClick:()=>{_e.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{e()}})};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:i,onClose:()=>s(!1),title:"Add an API Key",trapFocus:!0,onDragStart:g=>{g.stopPropagation()},children:a.jsx(ur,{postSubmit:p,styles:t,initialRoleID:n})}),a.jsx(f.Button,{size:t.button.size,onClick:l,leftIcon:a.jsx(ie.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function $t({id:e,name:t,onSuccess:n,styles:r=Je}){const i=_e.useModals(),s=async()=>{if(e){D.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await W.api_key.delete(e),D.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${t}] is deleted`,color:"green"}),n()}catch(d){D.updateNotification({id:"for-deleting",title:"Failed",message:d.message,color:"red"})}}},l=()=>i.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:s});return a.jsx(f.Button,{size:r.button.size,color:"red",onClick:l,leftIcon:a.jsx(ie.Trash,{size:20}),children:"Delete"})}function cr({styles:e=Je,config:t}){var d;Ae(t);const{data:n=[],loading:r,refresh:i}=he.useRequest(async()=>{const{data:p}=await W.api_key.list();return p},{refreshDeps:[]}),{data:s=[],loading:l}=he.useRequest(async()=>(await W.role.list()).map(g=>({label:g.id,value:g.id,description:g.description,disabled:g.id==="SUPERADMIN"})),{refreshDeps:[]});return a.jsxs(a.Fragment,{children:[a.jsx(f.Group,{pt:e.spacing,position:"right",children:a.jsx(Nt,{onSuccess:i,initialRoleID:((d=s==null?void 0:s[0])==null?void 0:d.value)??"INACTIVE"})}),a.jsxs(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a.jsx(f.LoadingOverlay,{visible:r||l}),a.jsxs(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Name"}),a.jsx("th",{children:"APP ID"}),a.jsx("th",{children:"Role"}),a.jsx("th",{children:"Action"})]})}),a.jsx("tbody",{children:n.map(p=>{const{id:g,name:m,app_id:c,role_id:u}=p;return a.jsxs("tr",{children:[a.jsx("td",{width:200,children:m}),a.jsx("td",{width:200,children:c}),a.jsx("td",{width:200,children:u}),a.jsx("td",{width:200,children:a.jsx(f.Group,{position:"left",children:a.jsx($t,{id:g,name:m,onSuccess:i})})})]},g)})})]})]})]})}const Ft=({value:e,onChange:t,height:n="200px",defaultLanguage:r="sql"})=>{const i=l=>{console.log("changing"),t==null||t(l??"")},s=!t;return a.jsx(Pe,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:e,onChange:s?void 0:i,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:s||!t}})},Ie={size:"sm",spacing:"md",button:{size:"xs"}};function dr({postSubmit:e,styles:t=Ie}){const{control:n,handleSubmit:r}=j.useForm({defaultValues:{id:"",content:""}}),i=async s=>{try{D.showNotification({id:"for-creating",title:"Pending",message:"Adding SQL Snippet...",loading:!0}),await W.sql_snippet.create(s),D.updateNotification({id:"for-creating",title:"Successful",message:"SQL Snippet is added",color:"green"}),e()}catch(l){D.updateNotification({id:"for-creating",title:"Failed",message:l.message,color:"red"})}};return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:r(i),children:[a.jsx(j.Controller,{name:"id",control:n,render:({field:s})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...s})}),a.jsx(j.Controller,{name:"content",control:n,render:({field:s})=>a.jsxs(f.Stack,{spacing:4,children:[a.jsx(f.Text,{size:14,fw:500,color:"#212529",sx:{cursor:"default"},children:"Content"}),a.jsx(Ft,{height:"600px",...s})]})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Pt({onSuccess:e,styles:t=Ie}){const[n,r]=k.useState(!1),i=()=>r(!0),s=()=>r(!1),l=()=>{s(),e()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:n,onClose:()=>r(!1),title:"Add a SQL Snippet",trapFocus:!0,onDragStart:d=>{d.stopPropagation()},size:"80vw",children:a.jsx(dr,{postSubmit:l,styles:t})}),a.jsx(f.Button,{size:t.button.size,onClick:i,leftIcon:a.jsx(ie.PlaylistAdd,{size:18}),children:"Add a SQL Snippet"})]})}function pr({postSubmit:e,styles:t=Ie,id:n,content:r}){const{control:i,handleSubmit:s}=j.useForm({defaultValues:{id:n,content:r}}),l=async d=>{try{D.showNotification({id:"for-updating",title:"Pending",message:"Updating SQL Snippet...",loading:!0}),await W.sql_snippet.update(d),D.updateNotification({id:"for-updating",title:"Successful",message:"SQL Snippet is updated",color:"green"}),e()}catch(p){D.updateNotification({id:"for-updating",title:"Failed",message:p.message,color:"red"})}};return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:s(l),children:[a.jsx(j.Controller,{name:"id",control:i,render:({field:d})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...d})}),a.jsx(j.Controller,{name:"content",control:i,render:({field:d})=>a.jsxs(f.Stack,{spacing:4,children:[a.jsx(f.Text,{size:14,fw:500,color:"#212529",sx:{cursor:"default"},children:"Content"}),a.jsx(Ft,{height:"600px",...d})]})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Bt({onSuccess:e,styles:t=Ie,...n}){const[r,i]=k.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{l(),e()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:"Edit a SQL Snippet",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},size:"80vw",children:a.jsx(pr,{postSubmit:d,styles:t,...n})}),a.jsx(f.Button,{size:t.button.size,onClick:s,leftIcon:a.jsx(ce.IconEdit,{size:18}),children:"Edit"})]})}/**
|
|
31
|
+
`)};function Kn({name:e,config:t,submit:n,styles:r=oe}){const{control:i,handleSubmit:s}=k.useForm({defaultValues:{config:t}});return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:s(n),children:[a.jsx(f.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Name",value:e,readOnly:!0}),a.jsx(f.Divider,{label:"Connection Info",labelPosition:"center"}),a.jsx(k.Controller,{name:"config.host",control:i,render:({field:l})=>a.jsx(f.TextInput,{mb:r.spacing,size:r.size,label:"Base URL",sx:{flexGrow:1},...l})}),a.jsxs(f.Group,{grow:!0,children:[a.jsx(k.Controller,{name:"config.processing.pre",control:i,render:({field:l})=>a.jsx(Xe,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:Dt.pre,...l,styles:r})}),a.jsx(k.Controller,{name:"config.processing.post",control:i,render:({field:l})=>a.jsx(Xe,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:Dt.post,...l,styles:r})})]}),a.jsx(f.Group,{position:"right",mt:r.spacing,children:a.jsx(f.Button,{type:"submit",size:r.button.size,children:"Save"})})]})})}function Zn({dataSource:e,postSubmit:t,styles:n=oe}){const r=async({config:i})=>{D.showNotification({id:"for-updating",title:"Pending",message:"Editing data source...",loading:!0,autoClose:!1});try{console.log({config:i}),await W.datasource.update(e.id,i),D.updateNotification({id:"for-updating",title:"Successful",message:"Data source is updated",color:"green",autoClose:!0}),t()}catch(s){D.updateNotification({id:"for-updating",title:"Failed",message:s.message,color:"red",autoClose:!0})}};return e.config?a.jsx(f.Box,{mx:"auto",children:a.jsx(Kn,{name:e.key,config:e.config,submit:r,styles:n})}):(console.error(new Error("unexpected empty config of a http datasource")),null)}function Xn({dataSource:e,onSuccess:t,styles:n=oe}){const[r,i]=C.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{t(),l()};return e.is_preset?a.jsx(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be changed",children:a.jsx(f.Button,{size:n.button.size,color:"gray",variant:"light",leftIcon:a.jsx(ce.IconLock,{size:16}),sx:{transform:"none !important"},children:"Edit"})}):e.type!=="http"?a.jsx(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"Only HTTP datasources can be edited",children:a.jsx(f.Button,{size:n.button.size,color:"gray",variant:"light",leftIcon:a.jsx(ce.IconEdit,{size:16}),sx:{transform:"none !important"},children:"Edit"})}):a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:"Add a data source",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a.jsx(Zn,{dataSource:e,postSubmit:d,styles:n})}),a.jsx(f.Button,{size:n.button.size,color:"blue",onClick:s,leftIcon:a.jsx(ce.IconEdit,{size:16}),children:"Edit"})]})}const Qn={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL"},Jn={http:a.jsx(ce.IconNetwork,{}),mysql:a.jsx(ce.IconBrandMysql,{}),postgresql:a.jsx(ce.IconDatabase,{})};function er({type:e}){return a.jsxs(f.Group,{children:[a.jsx(f.ActionIcon,{size:"xs",sx:{transform:"none !important"},children:Jn[e]}),a.jsx(f.Text,{sx:{cusor:"default",userSelect:"none"},children:Qn[e]})]})}function tr({styles:e=oe,config:t}){Wn(t.monacoPath),Ae(t);const{data:n=[],loading:r,refresh:i}=he.useRequest(async()=>{const{data:s}=await W.datasource.list();return s},{refreshDeps:[]});return a.jsxs(a.Fragment,{children:[a.jsx(f.Group,{pt:e.spacing,position:"right",children:a.jsx(Ot,{onSuccess:i})}),a.jsxs(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a.jsx(f.LoadingOverlay,{visible:r}),a.jsxs(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Type"}),a.jsx("th",{children:"Name"}),a.jsx("th",{children:"Action"})]})}),a.jsx("tbody",{children:n.map(s=>{const{id:l,key:d,type:p,is_preset:g}=s;return a.jsxs("tr",{children:[a.jsx("td",{width:200,children:a.jsx(er,{type:p})}),a.jsx("td",{children:d}),a.jsx("td",{width:400,children:a.jsxs(f.Group,{position:"left",children:[a.jsx(Xn,{dataSource:s,onSuccess:i,styles:e}),a.jsx(It,{isProtected:g,id:l,name:d,onSuccess:i,styles:e})]})})]},d)})})]})]})]})}const nr=C.forwardRef(({label:e,value:t,description:n,...r},i)=>a.jsxs(f.Stack,{spacing:2,ref:i,...r,children:[a.jsx(f.Text,{size:"sm",children:e}),a.jsx(f.Text,{size:"xs",color:"dimmed",className:"role-description",children:n})]})),ct=C.forwardRef(({styles:e,value:t,onChange:n},r)=>{const{data:i=[],loading:s}=he.useRequest(async()=>(await W.role.list()).map(d=>({label:d.id,value:d.id,description:d.description,disabled:d.id==="SUPERADMIN"})),{refreshDeps:[]});return a.jsx(f.Select,{ref:r,mb:e.spacing,size:e.size,required:!0,label:"Role",itemComponent:nr,data:i,disabled:s,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:n})}),ve={size:"sm",spacing:"md",button:{size:"xs"}};function rr({postSubmit:e,styles:t=ve,initialRoleID:n}){const{control:r,handleSubmit:i}=k.useForm({defaultValues:{name:"",email:"",role_id:n,password:""}}),s=async({name:l,email:d,password:p,role_id:g})=>{try{D.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0,autoClose:!1}),await W.account.create(l,d,p,g),D.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green",autoClose:!0}),e()}catch(m){D.updateNotification({id:"for-creating",title:"Failed",message:m.message,color:"red",autoClose:!0})}};return a.jsx(f.Box,{mx:"auto",mb:10,children:a.jsxs("form",{onSubmit:i(s),children:[a.jsx(k.Controller,{name:"name",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...l})}),a.jsx(k.Controller,{name:"email",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Email",...l})}),a.jsx(k.Controller,{name:"password",control:r,render:({field:l})=>a.jsx(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...l})}),a.jsx(k.Controller,{name:"role_id",control:r,render:({field:l})=>a.jsx(ct,{styles:t,...l})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Rt({onSuccess:e,styles:t=ve,initialRoleID:n}){const[r,i]=C.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{e(),l()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:"Add an Account",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a.jsx(rr,{postSubmit:d,styles:t,initialRoleID:n})}),a.jsx(f.Button,{size:t.button.size,onClick:s,leftIcon:a.jsx(ie.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Lt({id:e,name:t,onSuccess:n,styles:r=ve}){const i=_e.useModals(),s=async()=>{if(e){D.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0,autoClose:!1});try{await W.account.delete(e),D.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${t}] is deleted`,color:"green",autoClose:!0}),n()}catch(d){D.updateNotification({id:"for-deleting",title:"Failed",message:d.message,color:"red",autoClose:!0})}}},l=()=>i.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:s});return a.jsx(f.Button,{size:r.button.size,color:"red",onClick:l,leftIcon:a.jsx(ie.Trash,{size:20}),children:"Delete"})}function ar({id:e,name:t,email:n,role_id:r,postSubmit:i,styles:s=ve}){const{control:l,handleSubmit:d,watch:p}=k.useForm({defaultValues:{name:t,email:n,role_id:r,reset_password:!1,new_password:""}}),g=async({name:u,email:h,role_id:y,reset_password:b,new_password:w})=>{try{D.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0,autoClose:!1}),await W.account.edit({id:e,name:u.trim(),email:h.trim(),role_id:y,reset_password:b,new_password:w.trim()}),D.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green",autoClose:!0}),i()}catch(E){D.updateNotification({id:"for-updating",title:"Failed",message:E.message,color:"red",autoClose:!0})}},[m,c]=p(["reset_password","new_password"]);return a.jsx(f.Box,{mx:"auto",mb:10,children:a.jsxs("form",{onSubmit:d(g),children:[a.jsx(k.Controller,{name:"name",control:l,render:({field:u})=>a.jsx(f.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Username",...u})}),a.jsx(k.Controller,{name:"email",control:l,render:({field:u})=>a.jsx(f.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Email",...u})}),a.jsx(k.Controller,{name:"role_id",control:l,render:({field:u})=>a.jsx(ct,{styles:s,...u})}),a.jsx(f.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),a.jsx(k.Controller,{name:"reset_password",control:l,render:({field:u})=>a.jsx(f.Switch,{mb:s.spacing,size:s.size,label:"Reset password",checked:u.value,onChange:h=>u.onChange(h.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),m&&a.jsx(k.Controller,{name:"new_password",control:l,render:({field:u})=>a.jsx(f.PasswordInput,{autoComplete:"off",mb:s.spacing,size:s.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...u})}),a.jsx(f.Group,{position:"right",mt:s.spacing,children:a.jsx(f.Button,{type:"submit",size:s.button.size,children:"Submit"})})]})})}function ir({account:e,onSuccess:t,styles:n=ve}){const[r,i]=C.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{t(),l()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:`Editing ${e.name}`,trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a.jsx(ar,{...e,postSubmit:d,styles:n})}),a.jsx(f.Button,{size:n.button.size,onClick:s,leftIcon:a.jsx(ie.Edit,{size:20}),children:"Edit"})]})}function sr({styles:e=ve,config:t}){var d;Ae(t);const{data:n=[],loading:r,refresh:i}=he.useRequest(async()=>{const{data:p}=await W.account.list();return p},{refreshDeps:[]}),{data:s=[],loading:l}=he.useRequest(async()=>(await W.role.list()).map(g=>({label:g.id,value:g.id,description:g.description,disabled:g.id==="SUPERADMIN"})),{refreshDeps:[]});return a.jsxs(a.Fragment,{children:[a.jsx(f.Group,{pt:e.spacing,position:"right",children:a.jsx(Rt,{onSuccess:i,initialRoleID:((d=s==null?void 0:s[0])==null?void 0:d.value)??"INACTIVE"})}),a.jsxs(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a.jsx(f.LoadingOverlay,{visible:r||l}),a.jsxs(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Username"}),a.jsx("th",{children:"Email"}),a.jsx("th",{children:"Role"}),a.jsx("th",{children:"Action"})]})}),a.jsx("tbody",{children:n.map(p=>{const{id:g,name:m,email:c,role_id:u}=p;return a.jsxs("tr",{children:[a.jsx("td",{width:200,children:m}),a.jsx("td",{width:200,children:c}),a.jsx("td",{width:200,children:u}),a.jsx("td",{width:200,children:a.jsxs(f.Group,{position:"left",children:[a.jsx(ir,{account:p,onSuccess:i}),a.jsx(Lt,{id:g,name:m,onSuccess:i})]})})]},g)})})]})]})]})}function or({postSubmit:e,styles:t=ve}){const{control:n,handleSubmit:r}=k.useForm({defaultValues:{name:"",password:""}}),i=async({name:s,password:l})=>{try{D.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0,autoClose:!1});const d=await W.account.login(s.trim(),l.trim());window.localStorage.setItem("token",d.token),D.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green",autoClose:!0}),e(d)}catch(d){D.updateNotification({id:"for-login",title:"Login Failed",message:d.message,color:"red",autoClose:!0})}};return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:r(i),children:[a.jsx(k.Controller,{name:"name",control:n,render:({field:s})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...s})}),a.jsx(k.Controller,{name:"password",control:n,render:({field:s})=>a.jsx(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...s})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Submit"})})]})})}function lr({styles:e=ve,config:t,onSuccess:n}){return Ae(t),a.jsx(a.Fragment,{children:a.jsx(f.Box,{mt:e.spacing,sx:{position:"relative"},children:a.jsx(or,{styles:e,postSubmit:n})})})}const Je={size:"sm",spacing:"md",button:{size:"xs"}};function ur({postSubmit:e,styles:t=Je,initialRoleID:n}){const{control:r,handleSubmit:i}=k.useForm({defaultValues:{name:"",role_id:n}}),s=async({name:l,role_id:d})=>{try{D.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0,autoClose:!1});const{app_id:p,app_secret:g}=await W.api_key.create(l,d);D.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green",autoClose:!0}),e(p,g)}catch(p){D.updateNotification({id:"for-creating",title:"Failed",message:p.message,color:"red",autoClose:!0})}};return a.jsx(f.Box,{mx:"auto",mb:10,children:a.jsxs("form",{onSubmit:i(s),children:[a.jsx(k.Controller,{name:"name",control:r,render:({field:l})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...l})}),a.jsx(k.Controller,{name:"role_id",control:r,render:({field:l})=>a.jsx(ct,{styles:t,...l})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Nt({onSuccess:e,styles:t=Je,initialRoleID:n}){const r=_e.useModals(),[i,s]=C.useState(!1),l=()=>s(!0),d=()=>s(!1),p=(g,m)=>{d(),r.openModal({title:"API Key is generated",children:a.jsxs(f.Stack,{children:[a.jsx(f.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),a.jsx(f.TextInput,{defaultValue:g,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),a.jsx(f.TextInput,{defaultValue:m,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),a.jsx(f.Button,{size:"sm",onClick:()=>{_e.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{e()}})};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:i,onClose:()=>s(!1),title:"Add an API Key",trapFocus:!0,onDragStart:g=>{g.stopPropagation()},children:a.jsx(ur,{postSubmit:p,styles:t,initialRoleID:n})}),a.jsx(f.Button,{size:t.button.size,onClick:l,leftIcon:a.jsx(ie.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function $t({id:e,name:t,onSuccess:n,styles:r=Je}){const i=_e.useModals(),s=async()=>{if(e){D.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0,autoClose:!1});try{await W.api_key.delete(e),D.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${t}] is deleted`,color:"green",autoClose:!0}),n()}catch(d){D.updateNotification({id:"for-deleting",title:"Failed",message:d.message,color:"red",autoClose:!0})}}},l=()=>i.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:s});return a.jsx(f.Button,{size:r.button.size,color:"red",onClick:l,leftIcon:a.jsx(ie.Trash,{size:20}),children:"Delete"})}function cr({styles:e=Je,config:t}){var d;Ae(t);const{data:n=[],loading:r,refresh:i}=he.useRequest(async()=>{const{data:p}=await W.api_key.list();return p},{refreshDeps:[]}),{data:s=[],loading:l}=he.useRequest(async()=>(await W.role.list()).map(g=>({label:g.id,value:g.id,description:g.description,disabled:g.id==="SUPERADMIN"})),{refreshDeps:[]});return a.jsxs(a.Fragment,{children:[a.jsx(f.Group,{pt:e.spacing,position:"right",children:a.jsx(Nt,{onSuccess:i,initialRoleID:((d=s==null?void 0:s[0])==null?void 0:d.value)??"INACTIVE"})}),a.jsxs(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a.jsx(f.LoadingOverlay,{visible:r||l}),a.jsxs(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Name"}),a.jsx("th",{children:"APP ID"}),a.jsx("th",{children:"Role"}),a.jsx("th",{children:"Action"})]})}),a.jsx("tbody",{children:n.map(p=>{const{id:g,name:m,app_id:c,role_id:u}=p;return a.jsxs("tr",{children:[a.jsx("td",{width:200,children:m}),a.jsx("td",{width:200,children:c}),a.jsx("td",{width:200,children:u}),a.jsx("td",{width:200,children:a.jsx(f.Group,{position:"left",children:a.jsx($t,{id:g,name:m,onSuccess:i})})})]},g)})})]})]})]})}const Ft=({value:e,onChange:t,height:n="200px",defaultLanguage:r="sql"})=>{const i=l=>{console.log("changing"),t==null||t(l??"")},s=!t;return a.jsx(Pe,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:e,onChange:s?void 0:i,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:s||!t}})},Ie={size:"sm",spacing:"md",button:{size:"xs"}};function dr({postSubmit:e,styles:t=Ie}){const{control:n,handleSubmit:r}=k.useForm({defaultValues:{id:"",content:""}}),i=async s=>{try{D.showNotification({id:"for-creating",title:"Pending",message:"Adding SQL Snippet...",loading:!0,autoClose:!1}),await W.sql_snippet.create(s),D.updateNotification({id:"for-creating",title:"Successful",message:"SQL Snippet is added",color:"green",autoClose:!0}),e()}catch(l){D.updateNotification({id:"for-creating",title:"Failed",message:l.message,color:"red",autoClose:!0})}};return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:r(i),children:[a.jsx(k.Controller,{name:"id",control:n,render:({field:s})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...s})}),a.jsx(k.Controller,{name:"content",control:n,render:({field:s})=>a.jsxs(f.Stack,{spacing:4,children:[a.jsx(f.Text,{size:14,fw:500,color:"#212529",sx:{cursor:"default"},children:"Content"}),a.jsx(Ft,{height:"600px",...s})]})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Pt({onSuccess:e,styles:t=Ie}){const[n,r]=C.useState(!1),i=()=>r(!0),s=()=>r(!1),l=()=>{s(),e()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:n,onClose:()=>r(!1),title:"Add a SQL Snippet",trapFocus:!0,onDragStart:d=>{d.stopPropagation()},size:"80vw",children:a.jsx(dr,{postSubmit:l,styles:t})}),a.jsx(f.Button,{size:t.button.size,onClick:i,leftIcon:a.jsx(ie.PlaylistAdd,{size:18}),children:"Add a SQL Snippet"})]})}function pr({postSubmit:e,styles:t=Ie,id:n,content:r}){const{control:i,handleSubmit:s}=k.useForm({defaultValues:{id:n,content:r}}),l=async d=>{try{D.showNotification({id:"for-updating",title:"Pending",message:"Updating SQL Snippet...",loading:!0,autoClose:!1}),await W.sql_snippet.update(d),D.updateNotification({id:"for-updating",title:"Successful",message:"SQL Snippet is updated",color:"green",autoClose:!0}),e()}catch(p){D.updateNotification({id:"for-updating",title:"Failed",message:p.message,color:"red",autoClose:!0})}};return a.jsx(f.Box,{mx:"auto",children:a.jsxs("form",{onSubmit:s(l),children:[a.jsx(k.Controller,{name:"id",control:i,render:({field:d})=>a.jsx(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...d})}),a.jsx(k.Controller,{name:"content",control:i,render:({field:d})=>a.jsxs(f.Stack,{spacing:4,children:[a.jsx(f.Text,{size:14,fw:500,color:"#212529",sx:{cursor:"default"},children:"Content"}),a.jsx(Ft,{height:"600px",...d})]})}),a.jsx(f.Group,{position:"right",mt:t.spacing,children:a.jsx(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Bt({onSuccess:e,styles:t=Ie,...n}){const[r,i]=C.useState(!1),s=()=>i(!0),l=()=>i(!1),d=()=>{l(),e()};return a.jsxs(a.Fragment,{children:[a.jsx(f.Modal,{opened:r,onClose:()=>i(!1),title:"Edit a SQL Snippet",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},size:"80vw",children:a.jsx(pr,{postSubmit:d,styles:t,...n})}),a.jsx(f.Button,{size:t.button.size,onClick:s,leftIcon:a.jsx(ce.IconEdit,{size:18}),children:"Edit"})]})}/**
|
|
32
32
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
33
33
|
*
|
|
34
34
|
* @license MIT <https://opensource.org/licenses/MIT>
|
|
@@ -39,6 +39,6 @@ Check the top-level render call using <`+_+">.")}return S}}function cn(o,S){{if(
|
|
|
39
39
|
?|
|
|
40
40
|
|(?![\\s\\S])))+`,"m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}}),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})}(v),v.languages.git={comment:/^#.*/m,deleted:/^[-–].*/m,inserted:/^\+.*/m,string:/("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s--?\w+/}},coord:/^@@.*@@$/m,"commit-sha1":/^commit \w{40}$/m},v.languages.go=v.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),v.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete v.languages.go["class-name"],function(e){function t(n,r){return"___"+n.toUpperCase()+r+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,i,s){if(n.language===r){var l=n.tokenStack=[];n.code=n.code.replace(i,function(d){if(typeof s=="function"&&!s(d))return d;for(var p=l.length,g;n.code.indexOf(g=t(r,p))!==-1;)++p;return l[p]=d,g}),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language!==r||!n.tokenStack)return;n.grammar=e.languages[r];var i=0,s=Object.keys(n.tokenStack);function l(d){for(var p=0;p<d.length&&!(i>=s.length);p++){var g=d[p];if(typeof g=="string"||g.content&&typeof g.content=="string"){var m=s[i],c=n.tokenStack[m],u=typeof g=="string"?g:g.content,h=t(r,m),y=u.indexOf(h);if(y>-1){++i;var b=u.substring(0,y),w=new e.Token(r,e.tokenize(c,n.grammar),"language-"+r,c),E=u.substring(y+h.length),x=[];b&&x.push.apply(x,l([b])),x.push(w),E&&x.push.apply(x,l([E])),typeof g=="string"?d.splice.apply(d,[p,1].concat(x)):g.content=x}}else g.content&&l(g.content)}return d}l(n.tokens)}}})}(v),function(e){e.languages.handlebars={comment:/\{\{![\s\S]*?\}\}/,delimiter:{pattern:/^\{\{\{?|\}\}\}?$/,alias:"punctuation"},string:/(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][+-]?\d+)?/,boolean:/\b(?:false|true)\b/,block:{pattern:/^(\s*(?:~\s*)?)[#\/]\S+?(?=\s*(?:~\s*)?$|\s)/,lookbehind:!0,alias:"keyword"},brackets:{pattern:/\[[^\]]+\]/,inside:{punctuation:/\[|\]/,variable:/[\s\S]+/}},punctuation:/[!"#%&':()*+,.\/;<=>@\[\\\]^`{|}~]/,variable:/[^!"#%&'()*+,\/;<=>@\[\\\]^`{|}~\s]+/},e.hooks.add("before-tokenize",function(t){var n=/\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/g;e.languages["markup-templating"].buildPlaceholders(t,"handlebars",n)}),e.hooks.add("after-tokenize",function(t){e.languages["markup-templating"].tokenizePlaceholders(t,"handlebars")}),e.languages.hbs=e.languages.handlebars}(v),v.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},v.languages.webmanifest=v.languages.json,v.languages.less=v.languages.extend("css",{comment:[/\/\*[\s\S]*?\*\//,{pattern:/(^|[^\\])\/\/.*/,lookbehind:!0}],atrule:{pattern:/@[\w-](?:\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};\s]|\s+(?!\s))*?(?=\s*\{)/,inside:{punctuation:/[:()]/}},selector:{pattern:/(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};@\s]|\s+(?!\s))*?(?=\s*\{)/,inside:{variable:/@+[\w-]+/}},property:/(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/,operator:/[+\-*\/]/}),v.languages.insertBefore("less","property",{variable:[{pattern:/@[\w-]+\s*:/,inside:{punctuation:/:/}},/@@?[\w-]+/],"mixin-usage":{pattern:/([{;]\s*)[.#](?!\d)[\w-].*?(?=[(;])/,lookbehind:!0,alias:"function"}}),v.languages.makefile={comment:{pattern:/(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,lookbehind:!0},string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"builtin-target":{pattern:/\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,alias:"builtin"},target:{pattern:/^(?:[^:=\s]|[ \t]+(?![\s:]))+(?=\s*:(?!=))/m,alias:"symbol",inside:{variable:/\$+(?:(?!\$)[^(){}:#=\s]+|(?=[({]))/}},variable:/\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,keyword:/-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,function:{pattern:/(\()(?:abspath|addsuffix|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:list|s)?)(?=[ \t])/,lookbehind:!0},operator:/(?:::|[?:+!])?=|[|@]/,punctuation:/[:;(){}]/},v.languages.objectivec=v.languages.extend("c",{string:{pattern:/@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},keyword:/\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,operator:/-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete v.languages.objectivec["class-name"],v.languages.objc=v.languages.objectivec,v.languages.ocaml={comment:{pattern:/\(\*[\s\S]*?\*\)/,greedy:!0},char:{pattern:/'(?:[^\\\r\n']|\\(?:.|[ox]?[0-9a-f]{1,3}))'/i,greedy:!0},string:[{pattern:/"(?:\\(?:[\s\S]|\r\n)|[^\\\r\n"])*"/,greedy:!0},{pattern:/\{([a-z_]*)\|[\s\S]*?\|\1\}/,greedy:!0}],number:[/\b(?:0b[01][01_]*|0o[0-7][0-7_]*)\b/i,/\b0x[a-f0-9][a-f0-9_]*(?:\.[a-f0-9_]*)?(?:p[+-]?\d[\d_]*)?(?!\w)/i,/\b\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?\d[\d_]*)?(?!\w)/i],directive:{pattern:/\B#\w+/,alias:"property"},label:{pattern:/\B~\w+/,alias:"property"},"type-variable":{pattern:/\B'\w+/,alias:"function"},variant:{pattern:/`\w+/,alias:"symbol"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,boolean:/\b(?:false|true)\b/,"operator-like-punctuation":{pattern:/\[[<>|]|[>|]\]|\{<|>\}/,alias:"punctuation"},operator:/\.[.~]|:[=>]|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,punctuation:/;;|::|[(){}\[\].,:;#]|\b_\b/},v.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},v.languages.python["string-interpolation"].inside.interpolation.inside.rest=v.languages.python,v.languages.py=v.languages.python,v.languages.reason=v.languages.extend("clike",{string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,greedy:!0},"class-name":/\b[A-Z]\w*/,keyword:/\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/,operator:/\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:asr|land|lor|lsl|lsr|lxor|mod)\b/}),v.languages.insertBefore("reason","class-name",{char:{pattern:/'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'\\\r\n])'/,greedy:!0},constructor:/\b[A-Z]\w*\b(?!\s*\.)/,label:{pattern:/\b[a-z]\w*(?=::)/,alias:"symbol"}}),delete v.languages.reason.function,function(e){e.languages.sass=e.languages.extend("css",{comment:{pattern:/^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t].+)*/m,lookbehind:!0,greedy:!0}}),e.languages.insertBefore("sass","atrule",{"atrule-line":{pattern:/^(?:[ \t]*)[@+=].+/m,greedy:!0,inside:{atrule:/(?:@[\w-]+|[+=])/}}}),delete e.languages.sass.atrule;var t=/\$[-\w]+|#\{\$[-\w]+\}/,n=[/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|not|or)\b/,{pattern:/(\s)-(?=\s)/,lookbehind:!0}];e.languages.insertBefore("sass","property",{"variable-line":{pattern:/^[ \t]*\$.+/m,greedy:!0,inside:{punctuation:/:/,variable:t,operator:n}},"property-line":{pattern:/^[ \t]*(?:[^:\s]+ *:.*|:[^:\s].*)/m,greedy:!0,inside:{property:[/[^:\s]+(?=\s*:)/,{pattern:/(:)[^:\s]+/,lookbehind:!0}],punctuation:/:/,variable:t,operator:n,important:e.languages.sass.important}}}),delete e.languages.sass.property,delete e.languages.sass.important,e.languages.insertBefore("sass","punctuation",{selector:{pattern:/^([ \t]*)\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*)*/m,lookbehind:!0,greedy:!0}})}(v),v.languages.scss=v.languages.extend("css",{comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},atrule:{pattern:/@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,inside:{rule:/@[\w-]+/}},url:/(?:[-a-z]+-)?url(?=\()/i,selector:{pattern:/(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,inside:{parent:{pattern:/&/,alias:"important"},placeholder:/%[-\w]+/,variable:/\$[-\w]+|#\{\$[-\w]+\}/}},property:{pattern:/(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,inside:{variable:/\$[-\w]+|#\{\$[-\w]+\}/}}}),v.languages.insertBefore("scss","atrule",{keyword:[/@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,{pattern:/( )(?:from|through)(?= )/,lookbehind:!0}]}),v.languages.insertBefore("scss","important",{variable:/\$[-\w]+|#\{\$[-\w]+\}/}),v.languages.insertBefore("scss","function",{"module-modifier":{pattern:/\b(?:as|hide|show|with)\b/i,alias:"keyword"},placeholder:{pattern:/%[-\w]+/,alias:"selector"},statement:{pattern:/\B!(?:default|optional)\b/i,alias:"keyword"},boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"},operator:{pattern:/(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,lookbehind:!0}}),v.languages.scss.atrule.inside.rest=v.languages.scss,function(e){var t={pattern:/(\b\d+)(?:%|[a-z]+)/,lookbehind:!0},n={pattern:/(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)/,lookbehind:!0},r={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},url:{pattern:/\burl\((["']?).*?\1\)/i,greedy:!0},string:{pattern:/("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,greedy:!0},interpolation:null,func:null,important:/\B!(?:important|optional)\b/i,keyword:{pattern:/(^|\s+)(?:(?:else|for|if|return|unless)(?=\s|$)|@[\w-]+)/,lookbehind:!0},hexcode:/#[\da-f]{3,6}/i,color:[/\b(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)\b/i,{pattern:/\b(?:hsl|rgb)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:hsl|rgb)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,inside:{unit:t,number:n,function:/[\w-]+(?=\()/,punctuation:/[(),]/}}],entity:/\\[\da-f]{1,8}/i,unit:t,boolean:/\b(?:false|true)\b/,operator:[/~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.{2,3}|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/],number:n,punctuation:/[{}()\[\];:,]/};r.interpolation={pattern:/\{[^\r\n}:]+\}/,alias:"variable",inside:{delimiter:{pattern:/^\{|\}$/,alias:"punctuation"},rest:r}},r.func={pattern:/[\w-]+\([^)]*\).*/,inside:{function:/^[^(]+/,rest:r}},e.languages.stylus={"atrule-declaration":{pattern:/(^[ \t]*)@.+/m,lookbehind:!0,inside:{atrule:/^@[\w-]+/,rest:r}},"variable-declaration":{pattern:/(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:\{[^{}]*\}|\S.*|$)/m,lookbehind:!0,inside:{variable:/^\S+/,rest:r}},statement:{pattern:/(^[ \t]*)(?:else|for|if|return|unless)[ \t].+/m,lookbehind:!0,inside:{keyword:/^\S+/,rest:r}},"property-declaration":{pattern:/((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)(?!\s)[^{\r\n]*(?:;|[^{\r\n,]$(?!(?:\r?\n|\r)(?:\{|\2[ \t])))/m,lookbehind:!0,inside:{property:{pattern:/^[^\s:]+/,inside:{interpolation:r.interpolation}},rest:r}},selector:{pattern:/(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t])))/m,lookbehind:!0,inside:{interpolation:r.interpolation,comment:r.comment,punctuation:/[{},]/}},func:r.func,string:r.string,comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0,greedy:!0},interpolation:r.interpolation,punctuation:/[{}()\[\];:.]/}}(v),function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend("jsx",t),delete e.languages.tsx.parameter,delete e.languages.tsx["literal-property"];var n=e.languages.tsx.tag;n.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+n.pattern.source+")",n.pattern.flags),n.lookbehind=!0}(v),v.languages.wasm={comment:[/\(;[\s\S]*?;\)/,{pattern:/;;.*/,greedy:!0}],string:{pattern:/"(?:\\[\s\S]|[^"\\])*"/,greedy:!0},keyword:[{pattern:/\b(?:align|offset)=/,inside:{operator:/=/}},{pattern:/\b(?:(?:f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|neg?|nearest|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|sqrt|store(?:8|16|32)?|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))?|memory\.(?:grow|size))\b/,inside:{punctuation:/\./}},/\b(?:anyfunc|block|br(?:_if|_table)?|call(?:_indirect)?|data|drop|elem|else|end|export|func|get_(?:global|local)|global|if|import|local|loop|memory|module|mut|nop|offset|param|result|return|select|set_(?:global|local)|start|table|tee_local|then|type|unreachable)\b/],variable:/\$[\w!#$%&'*+\-./:<=>?@\\^`|~]+/,number:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/,punctuation:/[()]/};var fr={plain:{backgroundColor:"#2a2734",color:"#9a86fd"},styles:[{types:["comment","prolog","doctype","cdata","punctuation"],style:{color:"#6c6783"}},{types:["namespace"],style:{opacity:.7}},{types:["tag","operator","number"],style:{color:"#e09142"}},{types:["property","function"],style:{color:"#9a86fd"}},{types:["tag-id","selector","atrule-id"],style:{color:"#eeebff"}},{types:["attr-name"],style:{color:"#c4b9fe"}},{types:["boolean","string","entity","url","attr-value","keyword","control","directive","unit","statement","regex","atrule","placeholder","variable"],style:{color:"#ffcc99"}},{types:["deleted"],style:{textDecorationLine:"line-through"}},{types:["inserted"],style:{textDecorationLine:"underline"}},{types:["italic"],style:{fontStyle:"italic"}},{types:["important","bold"],style:{fontWeight:"bold"}},{types:["important"],style:{color:"#c4b9fe"}}]},gr={Prism:v,theme:fr};function Ue(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ye(){return ye=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ye.apply(this,arguments)}var hr=/\r\n|\r|\n/,zt=function(e){e.length===0?e.push({types:["plain"],content:`
|
|
41
41
|
`,empty:!0}):e.length===1&&e[0].content===""&&(e[0].content=`
|
|
42
|
-
`,e[0].empty=!0)},Mt=function(e,t){var n=e.length;return n>0&&e[n-1]===t?e:e.concat(t)},mr=function(e){for(var t=[[]],n=[e],r=[0],i=[e.length],s=0,l=0,d=[],p=[d];l>-1;){for(;(s=r[l]++)<i[l];){var g=void 0,m=t[l],c=n[l],u=c[s];if(typeof u=="string"?(m=l>0?m:["plain"],g=u):(m=Mt(m,u.type),u.alias&&(m=Mt(m,u.alias)),g=u.content),typeof g!="string"){l++,t.push(m),n.push(g),r.push(0),i.push(g.length);continue}var h=g.split(hr),y=h.length;d.push({types:m,content:h[0]});for(var b=1;b<y;b++)zt(d),p.push(d=[]),d.push({types:m,content:h[b]})}l--,t.pop(),n.pop(),r.pop(),i.pop()}return zt(d),p},br=function(e,t){var n=e.plain,r=Object.create(null),i=e.styles.reduce(function(s,l){var d=l.languages,p=l.style;return d&&!d.includes(t)||l.types.forEach(function(g){var m=ye({},s[g],p);s[g]=m}),s},r);return i.root=n,i.plain=ye({},n,{backgroundColor:null}),i};function Gt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)===-1&&(n[r]=e[r]);return n}var vr=function(e){function t(){for(var n=this,r=[],i=arguments.length;i--;)r[i]=arguments[i];e.apply(this,r),Ue(this,"getThemeDict",function(s){if(n.themeDict!==void 0&&s.theme===n.prevTheme&&s.language===n.prevLanguage)return n.themeDict;n.prevTheme=s.theme,n.prevLanguage=s.language;var l=s.theme?br(s.theme,s.language):void 0;return n.themeDict=l}),Ue(this,"getLineProps",function(s){var l=s.key,d=s.className,p=s.style,g=Gt(s,["key","className","style","line"]),m=g,c=ye({},m,{className:"token-line",style:void 0,key:void 0}),u=n.getThemeDict(n.props);return u!==void 0&&(c.style=u.plain),p!==void 0&&(c.style=c.style!==void 0?ye({},c.style,p):p),l!==void 0&&(c.key=l),d&&(c.className+=" "+d),c}),Ue(this,"getStyleForToken",function(s){var l=s.types,d=s.empty,p=l.length,g=n.getThemeDict(n.props);if(g!==void 0){{if(p===1&&l[0]==="plain")return d?{display:"inline-block"}:void 0;if(p===1&&!d)return g[l[0]]}var m=d?{display:"inline-block"}:{},c=l.map(function(u){return g[u]});return Object.assign.apply(Object,[m].concat(c))}}),Ue(this,"getTokenProps",function(s){var l=s.key,d=s.className,p=s.style,g=s.token,m=Gt(s,["key","className","style","token"]),c=m,u=ye({},c,{className:"token "+g.types.join(" "),children:g.content,style:n.getStyleForToken(g),key:void 0});return p!==void 0&&(u.style=u.style!==void 0?ye({},u.style,p):p),l!==void 0&&(u.key=l),d&&(u.className+=" "+d),u}),Ue(this,"tokenize",function(s,l,d,p){var g={code:l,grammar:d,language:p,tokens:[]};s.hooks.run("before-tokenize",g);var m=g.tokens=s.tokenize(g.code,g.grammar,g.language);return s.hooks.run("after-tokenize",g),m})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){var r=this.props,i=r.Prism,s=r.language,l=r.code,d=r.children,p=this.getThemeDict(this.props),g=i.languages[s],m=g!==void 0?this.tokenize(i,l,g,s):[l],c=mr(m);return d({tokens:c,className:"prism-code language-"+s,style:p!==void 0?p.root:{},getLineProps:this.getLineProps,getTokenProps:this.getTokenProps})},t}(
|
|
43
|
-
`).length.toString().length,P=f.useMantineTheme(),Y=mn.useClipboard(),B=y||P.colorScheme,{classes:J,cx:F}=_r({colorScheme:B,native:h!==f.ScrollArea,maxLineSize:X,radius:E},{name:"Prism",classNames:d,styles:p,unstyled:w,variant:A});return
|
|
44
|
-
`)return null;const re=ee+1,pe=M({line:Z,key:ee}),we=re in u,fe=B==="dark"?P.fn.rgba(P.fn.themeColor((le=u[re])==null?void 0:le.color,9),.25):P.fn.themeColor((ue=u[re])==null?void 0:ue.color,0);return
|
|
42
|
+
`,e[0].empty=!0)},Mt=function(e,t){var n=e.length;return n>0&&e[n-1]===t?e:e.concat(t)},mr=function(e){for(var t=[[]],n=[e],r=[0],i=[e.length],s=0,l=0,d=[],p=[d];l>-1;){for(;(s=r[l]++)<i[l];){var g=void 0,m=t[l],c=n[l],u=c[s];if(typeof u=="string"?(m=l>0?m:["plain"],g=u):(m=Mt(m,u.type),u.alias&&(m=Mt(m,u.alias)),g=u.content),typeof g!="string"){l++,t.push(m),n.push(g),r.push(0),i.push(g.length);continue}var h=g.split(hr),y=h.length;d.push({types:m,content:h[0]});for(var b=1;b<y;b++)zt(d),p.push(d=[]),d.push({types:m,content:h[b]})}l--,t.pop(),n.pop(),r.pop(),i.pop()}return zt(d),p},br=function(e,t){var n=e.plain,r=Object.create(null),i=e.styles.reduce(function(s,l){var d=l.languages,p=l.style;return d&&!d.includes(t)||l.types.forEach(function(g){var m=ye({},s[g],p);s[g]=m}),s},r);return i.root=n,i.plain=ye({},n,{backgroundColor:null}),i};function Gt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)===-1&&(n[r]=e[r]);return n}var vr=function(e){function t(){for(var n=this,r=[],i=arguments.length;i--;)r[i]=arguments[i];e.apply(this,r),Ue(this,"getThemeDict",function(s){if(n.themeDict!==void 0&&s.theme===n.prevTheme&&s.language===n.prevLanguage)return n.themeDict;n.prevTheme=s.theme,n.prevLanguage=s.language;var l=s.theme?br(s.theme,s.language):void 0;return n.themeDict=l}),Ue(this,"getLineProps",function(s){var l=s.key,d=s.className,p=s.style,g=Gt(s,["key","className","style","line"]),m=g,c=ye({},m,{className:"token-line",style:void 0,key:void 0}),u=n.getThemeDict(n.props);return u!==void 0&&(c.style=u.plain),p!==void 0&&(c.style=c.style!==void 0?ye({},c.style,p):p),l!==void 0&&(c.key=l),d&&(c.className+=" "+d),c}),Ue(this,"getStyleForToken",function(s){var l=s.types,d=s.empty,p=l.length,g=n.getThemeDict(n.props);if(g!==void 0){{if(p===1&&l[0]==="plain")return d?{display:"inline-block"}:void 0;if(p===1&&!d)return g[l[0]]}var m=d?{display:"inline-block"}:{},c=l.map(function(u){return g[u]});return Object.assign.apply(Object,[m].concat(c))}}),Ue(this,"getTokenProps",function(s){var l=s.key,d=s.className,p=s.style,g=s.token,m=Gt(s,["key","className","style","token"]),c=m,u=ye({},c,{className:"token "+g.types.join(" "),children:g.content,style:n.getStyleForToken(g),key:void 0});return p!==void 0&&(u.style=u.style!==void 0?ye({},u.style,p):p),l!==void 0&&(u.key=l),d&&(u.className+=" "+d),u}),Ue(this,"tokenize",function(s,l,d,p){var g={code:l,grammar:d,language:p,tokens:[]};s.hooks.run("before-tokenize",g);var m=g.tokens=s.tokenize(g.code,g.grammar,g.language);return s.hooks.run("after-tokenize",g),m})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){var r=this.props,i=r.Prism,s=r.language,l=r.code,d=r.children,p=this.getThemeDict(this.props),g=i.languages[s],m=g!==void 0?this.tokenize(i,l,g,s):[l],c=mr(m);return d({tokens:c,className:"prism-code language-"+s,style:p!==void 0?p.root:{},getLineProps:this.getLineProps,getTokenProps:this.getTokenProps})},t}(C.Component);const yr=vr;function Ut({copied:e}){return C.createElement("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"1rem",height:"1rem"}},e?C.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}):C.createElement("path",{d:"M5 2V1H10V2H5ZM4.75 0C4.33579 0 4 0.335786 4 0.75V1H3.5C2.67157 1 2 1.67157 2 2.5V12.5C2 13.3284 2.67157 14 3.5 14H11.5C12.3284 14 13 13.3284 13 12.5V2.5C13 1.67157 12.3284 1 11.5 1H11V0.75C11 0.335786 10.6642 0 10.25 0H4.75ZM11 2V2.25C11 2.66421 10.6642 3 10.25 3H4.75C4.33579 3 4 2.66421 4 2.25V2H3.5C3.22386 2 3 2.22386 3 2.5V12.5C3 12.7761 3.22386 13 3.5 13H11.5C11.7761 13 12 12.7761 12 12.5V2.5C12 2.22386 11.7761 2 11.5 2H11Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}))}Ut.displayName="@mantine/prism/CopyIcon";const Sr=e=>({plain:{color:e.colors.gray[4],backgroundColor:e.colors.dark[8]},styles:[{types:["comment"],style:{color:e.colors.gray[6]}},{types:["string","inserted","selector","atrule"],style:{color:e.colors.teal[4]}},{types:["number"],style:{color:e.colors.blue[4]}},{types:["builtin","char","constant","function"],style:{color:e.colors.orange[5]}},{types:["punctuation"],style:{color:e.colors.gray[5]}},{types:["variable"],style:{color:e.colors.gray[5]}},{types:["class-name","attr-name"],style:{color:e.colors.yellow[5]}},{types:["tag","deleted"],style:{color:e.colors.red[6]}},{types:["operator"],style:{color:e.colors.gray[5]}},{types:["boolean"],style:{color:e.colors.red[6]}},{types:["keyword"],style:{color:e.colors.indigo[3]}},{types:["doctype"],style:{color:e.colors.gray[5]}},{types:["url"],style:{color:e.colors.gray[5]}}]}),xr=e=>({plain:{color:e.colors.gray[9],backgroundColor:e.fn.rgba(e.colors.gray[0],.65)},styles:[{types:["comment"],style:{color:e.colors.gray[6]}},{types:["string","inserted"],style:{color:e.colors.indigo[9]}},{types:["number"],style:{color:e.colors.blue[7]}},{types:["builtin","char","constant","function","selector","atrule"],style:{color:e.colors.lime[9]}},{types:["punctuation"],style:{color:e.colors.gray[7]}},{types:["variable"],style:{color:e.colors.violet[9]}},{types:["attr-name"],style:{color:e.colors.green[9]}},{types:["class-name"],style:{color:e.colors.red[9]}},{types:["tag","deleted"],style:{color:e.colors.violet[9]}},{types:["operator"],style:{color:e.colors.red[9]}},{types:["boolean"],style:{color:e.colors.red[9]}},{types:["keyword"],style:{color:e.colors.red[9]}},{types:["doctype"],style:{color:e.colors.gray[7]}},{types:["url"],style:{color:e.colors.gray[7]}}]}),wr=(e,t)=>t==="dark"?Sr(e):xr(e);var Er=f.createStyles((e,{colorScheme:t,native:n,maxLineSize:r,radius:i})=>({scrollArea:{},root:{position:"relative"},code:{boxSizing:"border-box",position:"relative",fontFamily:e.fontFamilyMonospace,lineHeight:1.7,fontSize:f.rem(13),overflowX:n?"auto":void 0,borderRadius:e.fn.radius(i),padding:`${e.spacing.sm} 0`,"&.mantine-Prism-code":{marginTop:0,marginBottom:0}},copy:{position:"absolute",top:e.spacing.xs,right:e.dir==="ltr"?e.spacing.xs:"unset",left:e.dir==="rtl"?e.spacing.xs:"unset",zIndex:2,"&, &:hover":{backgroundColor:t==="dark"?e.colors.dark[8]:e.colors.gray[0]}},line:{display:"flex",width:"100%",padding:`0 ${e.spacing.md}`},lineNumber:{color:t==="dark"?e.colors.dark[4]:e.colors.gray[4],textAlign:"right",width:`calc(8 * ${f.rem(r)})`,marginRight:e.dir==="ltr"?e.spacing.xs:void 0,marginLeft:e.dir==="rtl"?e.spacing.xs:void 0,userSelect:"none"},lineContent:{width:"100%"}}));const _r=Er;var Ar=Object.defineProperty,Tr=Object.defineProperties,Cr=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,Ht=(e,t,n)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,De=(e,t)=>{for(var n in t||(t={}))qt.call(t,n)&&Ht(e,n,t[n]);if(et)for(var n of et(t))Yt.call(t,n)&&Ht(e,n,t[n]);return e},qe=(e,t)=>Tr(e,Cr(t)),kr=(e,t)=>{var n={};for(var r in e)qt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&et)for(var r of et(e))t.indexOf(r)<0&&Yt.call(e,r)&&(n[r]=e[r]);return n};const jr={noCopy:!1,copyLabel:"Copy code",copiedLabel:"Copied",withLineNumbers:!1,trim:!0,highlightLines:{},scrollAreaComponent:f.ScrollArea,getPrismTheme:wr},pt=C.forwardRef((e,t)=>{const n=f.useComponentDefaultProps("Prism",jr,e),{className:r,children:i,language:s,noCopy:l,classNames:d,styles:p,copyLabel:g,copiedLabel:m,withLineNumbers:c,highlightLines:u,scrollAreaComponent:h,colorScheme:y,trim:b,unstyled:w,radius:E,getPrismTheme:x,variant:A}=n,O=kr(n,["className","children","language","noCopy","classNames","styles","copyLabel","copiedLabel","withLineNumbers","highlightLines","scrollAreaComponent","colorScheme","trim","unstyled","radius","getPrismTheme","variant"]),q=b&&typeof i=="string"?i.trim():i,X=q.split(`
|
|
43
|
+
`).length.toString().length,P=f.useMantineTheme(),Y=mn.useClipboard(),B=y||P.colorScheme,{classes:J,cx:F}=_r({colorScheme:B,native:h!==f.ScrollArea,maxLineSize:X,radius:E},{name:"Prism",classNames:d,styles:p,unstyled:w,variant:A});return C.createElement(f.Box,qe(De({className:F(J.root,r),ref:t},O),{translate:"no"}),!l&&C.createElement(f.Tooltip,{label:Y.copied?m:g,position:"left",withArrow:!0,arrowSize:6,offset:6,color:Y.copied?"teal":void 0,unstyled:w},C.createElement(f.ActionIcon,{className:J.copy,"aria-label":Y.copied?m:g,onClick:()=>Y.copy(q),unstyled:w},C.createElement(Ut,{copied:Y.copied}))),C.createElement(yr,qe(De({},gr),{theme:x(P,B),code:q,language:s}),({className:K,style:G,tokens:Q,getLineProps:M,getTokenProps:ne})=>C.createElement(h,{className:J.scrollArea,dir:"ltr"},C.createElement("pre",{className:F(J.code,K),style:G,dir:"ltr"},Q.map((Z,ee)=>{var le,ue,de,Se;if(ee===Q.length-1&&Z.length===1&&Z[0].content===`
|
|
44
|
+
`)return null;const re=ee+1,pe=M({line:Z,key:ee}),we=re in u,fe=B==="dark"?P.fn.rgba(P.fn.themeColor((le=u[re])==null?void 0:le.color,9),.25):P.fn.themeColor((ue=u[re])==null?void 0:ue.color,0);return C.createElement("div",qe(De({},pe),{className:F(J.line,pe.className),style:De({},we?{backgroundColor:fe}:null)}),c&&C.createElement("div",{className:J.lineNumber,style:{color:we?P.fn.themeColor((de=u[re])==null?void 0:de.color,B==="dark"?5:8):void 0}},((Se=u[re])==null?void 0:Se.label)||re),C.createElement("div",{className:J.lineContent},Z.map((He,Re)=>{var Le,Ee;const Ne=ne({token:He,key:Re});return C.createElement("span",qe(De({},Ne),{style:qe(De({},Ne.style),{color:we?P.fn.themeColor((Le=u[re])==null?void 0:Le.color,B==="dark"?5:8):(Ee=Ne==null?void 0:Ne.style)==null?void 0:Ee.color})}))})))}).filter(Boolean)))))});pt.displayName="@mantine/prism/Prism";var Or=f.createStyles((e,{radius:t})=>({tab:{paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,height:f.rem(34),border:`${f.rem(1)} solid ${e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[3]}`,borderBottom:0,fontSize:e.fontSizes.sm,color:e.colorScheme==="dark"?e.colors.dark[1]:e.colors.gray[7],backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white,borderRadius:0,"&:first-of-type":{borderTopLeftRadius:e.radius.sm},"&:not(:first-of-type)":{borderLeft:0},"&:last-of-type":{borderTopRightRadius:e.radius.sm},"&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[7]:e.colors.gray[0]},"&[data-active]":{color:e.colorScheme==="dark"?e.white:e.black,backgroundColor:e.colorScheme==="dark"?e.colors.dark[8]:e.fn.rgba(e.colors.gray[0],.65),"&::before":{backgroundColor:"transparent"}}},prism:{borderRadius:e.fn.radius(t),borderTopRightRadius:0,borderTopLeftRadius:0,border:`${f.rem(1)} solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,borderTop:0,overflow:"hidden"},code:{borderTopRightRadius:0,borderTopLeftRadius:0,border:0}}));const Vt=Or;var Ir=Object.defineProperty,Dr=Object.defineProperties,Rr=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,Wt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable,Zt=(e,t,n)=>t in e?Ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xt=(e,t)=>{for(var n in t||(t={}))Wt.call(t,n)&&Zt(e,n,t[n]);if(tt)for(var n of tt(t))Kt.call(t,n)&&Zt(e,n,t[n]);return e},Lr=(e,t)=>Dr(e,Rr(t)),Nr=(e,t)=>{var n={};for(var r in e)Wt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&tt)for(var r of tt(e))t.indexOf(r)<0&&Kt.call(e,r)&&(n[r]=e[r]);return n};function $r(e){const{classes:t}=Vt({radius:e.radius});return C.createElement(f.Tabs,Lr(Xt({},e),{variant:"outline",classNames:{tab:t.tab},translate:"no"}))}function Fr(e){var t=e,{language:n,children:r,radius:i,noCopy:s,copyLabel:l,copiedLabel:d,withLineNumbers:p,highlightLines:g,scrollAreaComponent:m,trim:c,getPrismTheme:u,colorScheme:h,variant:y}=t,b=Nr(t,["language","children","radius","noCopy","copyLabel","copiedLabel","withLineNumbers","highlightLines","scrollAreaComponent","trim","getPrismTheme","colorScheme","variant"]);const{classes:w}=Vt({radius:i});return C.createElement(f.Tabs.Panel,Xt({},b),C.createElement(pt,{language:n,classNames:{root:w.prism,code:w.code},radius:i,noCopy:s,copyLabel:l,copiedLabel:d,withLineNumbers:p,highlightLines:g,scrollAreaComponent:m,trim:c,getPrismTheme:u,colorScheme:h,variant:y},r))}const Ye=pt;Ye.Tabs=$r,Ye.Tab=f.Tabs.Tab,Ye.TabsList=f.Tabs.List,Ye.Panel=Fr;function Qt({id:e,onSuccess:t,styles:n=Ie}){const r=_e.useModals(),i=async()=>{if(e){D.showNotification({id:"for-deleting",title:"Pending",message:"Deleting SQL Snippet...",loading:!0,autoClose:!1});try{await W.sql_snippet.delete(e),D.updateNotification({id:"for-deleting",title:"Successful",message:`SQL Snippet [${e}] is deleted`,color:"green",autoClose:!0}),t()}catch(l){D.updateNotification({id:"for-deleting",title:"Failed",message:l.message,color:"red",autoClose:!0})}}},s=()=>r.openConfirmModal({title:"Delete this SQL Snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i,confirmProps:{color:"red"}});return a.jsx(f.Button,{size:n.button.size,color:"red",onClick:s,leftIcon:a.jsx(ie.Trash,{size:20}),children:"Delete"})}function Pr({content:e}){return a.jsxs(f.HoverCard,{width:"60vw",shadow:"md",children:[a.jsx(f.HoverCard.Target,{children:a.jsx(f.ActionIcon,{size:16,children:a.jsx(ce.IconEye,{})})}),a.jsx(f.HoverCard.Dropdown,{children:a.jsx(Ye,{language:"sql",noCopy:!0,withLineNumbers:!0,children:e})})]})}function Br({styles:e=Ie,config:t}){Ae(t);const{data:n=[],loading:r,refresh:i}=he.useRequest(async()=>{const{data:s}=await W.sql_snippet.list({pagination:{page:1,pagesize:10}});return s},{refreshDeps:[]});return a.jsxs(a.Fragment,{children:[a.jsx(f.Group,{pt:e.spacing,position:"right",children:a.jsx(Pt,{onSuccess:i})}),a.jsxs(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a.jsx(f.LoadingOverlay,{visible:r}),a.jsxs(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Name"}),a.jsx("th",{}),a.jsx("th",{children:"Created At"}),a.jsx("th",{children:"Updated At"}),a.jsx("th",{children:"Action"})]})}),a.jsx("tbody",{children:n.map(s=>{const{id:l,content:d,create_time:p,update_time:g}=s;return a.jsxs("tr",{children:[a.jsx("td",{children:l}),a.jsx("td",{width:50,children:a.jsx(Pr,{content:d})}),a.jsx("td",{width:200,children:p}),a.jsx("td",{width:200,children:g}),a.jsx("td",{width:400,children:a.jsxs(f.Group,{position:"left",children:[a.jsx(Bt,{...s,onSuccess:i}),a.jsx(Qt,{id:l,onSuccess:i})]})})]},l)})})]})]})]})}const zr=()=>Promise.resolve().then(()=>Mr).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e)),Mr=Object.freeze(Object.defineProperty({__proto__:null,version:"12.10.2"},Symbol.toStringTag,{value:"Module"}));j.APIClient=z,j.APIKeyList=cr,j.AccountList=sr,j.AddAPIKey=Nt,j.AddAccount=Rt,j.AddDataSource=Ot,j.AddSQLSnippet=Pt,j.DataSourceList=tr,j.DefaultApiClient=St,j.DeleteAPIKey=$t,j.DeleteAccount=Lt,j.DeleteDataSource=It,j.DeleteSQLSnippet=Qt,j.FacadeApiClient=xt,j.Login=lr,j.SQLSnippetList=Br,j.UpdateSQLSnippet=Bt,j.configureAPIClient=Ae,j.facadeApiClient=wt,j.getVersion=zr,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|